iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Is it possible to change webgrid's ActiveFrozenColumns property on client side?
If yes, could somebody give me some sample code.
Thanx in advance.
Sudeep
Hi Andi,
Thanx a lot for the sample code.
This is what I was looking for.
grid.LayoutSettings.FreezePaneSettings.ActiveFrozenColumns = 2;
grid.FreezePane(true);}
}
grid.UnfreezePane();
I found the solution in the thread:
http://www.intersoftpt.com/Community/WebGrid/Freeze-columns-from-client-side-on-the-grid/
I'm putting the code so that if somebody happens to need this kind of behaviour, they can find it in this thread.
Thanks guys.
Hi Sudeep,
Yes, you absolutely can change the WebGrid's ActiveFrozenColumns property on client side. Here are the sample code that I made using a HTML button to change its value.function Button1_onclick() { var wg = ISGetObject("WebGrid1"); var grid = wg.RootTable; grid.Layout.FreezePaneSettings.MaxFrozenColumns = "5"; grid.Layout.FreezePaneSettings.ActiveFrozenColumns = "1"; wg.RefreshAll(); } I hope it helps, and please do not hesitate to ask if you have any other questions. Thank you, Andi Santoso
function Button1_onclick() { var wg = ISGetObject("WebGrid1"); var grid = wg.RootTable; grid.Layout.FreezePaneSettings.MaxFrozenColumns = "5"; grid.Layout.FreezePaneSettings.ActiveFrozenColumns = "1"; wg.RefreshAll(); }
I hope it helps, and please do not hesitate to ask if you have any other questions.
Thank you,
Andi Santoso
Hello Andi,
Thanx for the reply. Well, It doesn't seem to work for me, don't know why. Is there a way to access the context menu's "Freeze pane" event. I just need to use it without the contect menu.
Thanx.
I have tried the code that Andi wrote and works fine in my end. Have you set the AllowColumnFreezing="Yes"? You can set it in WebGrid Designer's properties>LayoutSettings>AllowColumnFreezing. If the solution still didn't works, could you give me a sample, so I can investigate it further?
Also I am really sorry but we cannot give you the code that used in "Freeze Column".
Thanks
Regards,
Julia
Hi Julia,
It works now. Thank you Julia and Andi.
There's still some problem, it refreshes everything. I mean like if i've already expanded the rows, all of it is lost. Can I call the method called by Freeze Pane command in the context menu.
Also, I can see that there's a method in WebGrid called FreezePane( ) in the javascript. How to use that method?
If anyone has already used that method, could you please give some sample code to me. It would be really helpful.
Thanks.
P.S.: I've attached an image of the webgrid. It shows double line when I freeze the second column using the code provided and then unfreeze it using the context menu and then again freeze the first column. Is it a bug or my layout problem?
* Double post
Unfortunately, that is the WebGrid behaviour since we are trying to refresh the data and structure of the WebGrid by changing active number of column freezing. As you notice, the method FreezePane is already in the context menu of its header column and it automatically ignite when we use it in the context menu. The alternative way to have a column freezing function, is by creating our own sub-context menu that will change the active number of column freezing. Here are the sample code that I make to change it by one or two.function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) { var WebGrid1 = ISGetObject(controlId); var FreezingOneColumn = new WebMenuItem(); var FreezingTwoColumn = new WebMenuItem(); FreezingOneColumn.Text = "<asp:Literal runat="server" Text="Column Freezing One" />"; FreezingOneColumn.Name = "ColumnFreezing"; FreezingOneColumn.OnClick = "ViewColumnFreezing"; FreezingOneColumn.CustomElement = controlId; FreezingTwoColumn.Text = "<asp:Literal runat="server" Text="Column Freezing Two" />"; FreezingTwoColumn.Name = "ColumnFreezing2"; FreezingTwoColumn.OnClick = "ViewColumnFreezing2"; FreezingTwoColumn.CustomElement = controlId; menuObject.Items.Add(FreezingOneColumn); menuObject.Items.Add(FreezingTwoColumn); return true; } function ColumnFreezingTwo(controlId) { var grid = ISGetObject(controlId); var rootTable = grid.RootTable; rootTable.Layout.FreezePaneSettings.MaxFrozenColumns = "4"; rootTable.Layout.FreezePaneSettings.ActiveFrozenColumns = "2"; grid.RefreshAll(); return true; } function ColumnFreezingOne(controlId) { var grid = ISGetObject(controlId); var rootTable = grid.RootTable; rootTable.Layout.FreezePaneSettings.MaxFrozenColumns = "4"; rootTable.Layout.FreezePaneSettings.ActiveFrozenColumns = "1"; grid.RefreshAll(); return true; } function ViewColumnFreezing(menuItem) { return ColumnFreezingOne(menuItem.CustomElement); } function ViewColumnFreezing2(menuItem) { return ColumnFreezingTwo(menuItem.CustomElement); } And for the layout problem, I cannot replicate your issue. It works just fine on my sample. Have you tried it on different browser? If it works fine on the other, perhaps it is just a browser issue. I hope it helps and please do not hesitate to ask if you have any other questions. Thank you,Andi Santoso.
function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) { var WebGrid1 = ISGetObject(controlId); var FreezingOneColumn = new WebMenuItem(); var FreezingTwoColumn = new WebMenuItem(); FreezingOneColumn.Text = "<asp:Literal runat="server" Text="Column Freezing One" />"; FreezingOneColumn.Name = "ColumnFreezing"; FreezingOneColumn.OnClick = "ViewColumnFreezing"; FreezingOneColumn.CustomElement = controlId; FreezingTwoColumn.Text = "<asp:Literal runat="server" Text="Column Freezing Two" />"; FreezingTwoColumn.Name = "ColumnFreezing2"; FreezingTwoColumn.OnClick = "ViewColumnFreezing2"; FreezingTwoColumn.CustomElement = controlId; menuObject.Items.Add(FreezingOneColumn); menuObject.Items.Add(FreezingTwoColumn); return true; } function ColumnFreezingTwo(controlId) { var grid = ISGetObject(controlId); var rootTable = grid.RootTable; rootTable.Layout.FreezePaneSettings.MaxFrozenColumns = "4"; rootTable.Layout.FreezePaneSettings.ActiveFrozenColumns = "2"; grid.RefreshAll(); return true; } function ColumnFreezingOne(controlId) { var grid = ISGetObject(controlId); var rootTable = grid.RootTable; rootTable.Layout.FreezePaneSettings.MaxFrozenColumns = "4"; rootTable.Layout.FreezePaneSettings.ActiveFrozenColumns = "1"; grid.RefreshAll(); return true; } function ViewColumnFreezing(menuItem) { return ColumnFreezingOne(menuItem.CustomElement); } function ViewColumnFreezing2(menuItem) { return ColumnFreezingTwo(menuItem.CustomElement); }
And for the layout problem, I cannot replicate your issue. It works just fine on my sample. Have you tried it on different browser? If it works fine on the other, perhaps it is just a browser issue. I hope it helps and please do not hesitate to ask if you have any other questions.
Thank you,Andi Santoso.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname