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
How to do custom row sorting in Web grid
Hello,Thank you for the question regarding WebGrid.You could do a custom sorting in “OnCustumSort” WebGrid’s server side event.Here’s the example snippet code regarding custom sorting:
protected void WebGrid1_CustomSort(object sender, ISNet.WebUI.WebGrid.SortEventArgs e){ WebGridGroup sortCol; sortCol = e.SortColumns.GetNamedItem("ContactName"); WebGridGroup oldSortCol; oldSortCol = e.SortColumns.GetNamedItem("CustomerID"); if (oldSortCol != null) { sortCol = new WebGridGroup(); sortCol.Table = oldSortCol.Table; sortCol.ColumnMember = "ContactName"; if (e.SortColumns.GetNamedItem("CustomerID").SortOrder == SortOrder.Ascending) { sortCol.SortOrder = SortOrder.Ascending; } else if (e.SortColumns.GetNamedItem("CustomerID").SortOrder == SortOrder.Descending) { sortCol.SortOrder = SortOrder.Descending; } e.SortColumns.Remove(oldSortCol); e.SortColumns.Add(sortCol); } }
Hi Hans,
Is there a way I can omit one row from getting sorted.
I have below grid
Sl. No
Name
Mob. No.
ID Mo.
Numeric Value
Alphabetical Value
1
Dev
123456789
555444666
2
Ashish
987654321
666444555
On click of the column header I don’t want the row-0 to change its position.
Regards, Dev
I'm afraid that it is not possible to omit a row while sorting. In custom sorting approach, we simply define the Table; ColumnMember; and SortOrder of WebGridGroup object and there is no such options that meet your scenario.
Hi,
For a workaround can we have two header rows in a grid i.e.one header and other sub header?
Regards,Dev
can we have two header rows in a grid?
Yes, you can utilize the ColumnSet feature to have two header rows in a grid. For example: following snippet code will create two header rows in WebGrid based on the grid's layout that you post on March 5, 2015.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" ...> <RootTable DataKeyField="CustomerID" RowLayout="ColumnSet"> <Columns> <ISWebGrid:WebGridColumn Caption="Numeric Value" DataMember="CustomerID" Name="CustomerID" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Alphabetical Value" DataMember="CompanyName" Name="CompanyName" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Numeric Value" DataMember="ContactName" Name="ContactName" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Numeric Value" DataMember="ContactTitle" Name="ContactTitle" Width="100px"> </ISWebGrid:WebGridColumn> </Columns> <ColumnSets> <ISWebGrid:WebGridColumnSet Caption="SI. No" ColumnCount="1" Name="ColumnSet0" Width="100px"> <Layout> <ISWebGrid:WebGridRowLayout ColumnMember="[set your SI.No column member in here]" /> </Layout> </ISWebGrid:WebGridColumnSet> <ISWebGrid:WebGridColumnSet Caption="Name" ColumnCount="1" Name="ColumnSet1" Width="100px"> <Layout> <ISWebGrid:WebGridRowLayout ColumnMember="[set your Name column member in here]" /> </Layout> </ISWebGrid:WebGridColumnSet> <ISWebGrid:WebGridColumnSet Caption="Mob. No." ColumnCount="1" Name="ColumnSet2" Width="100px"> <Layout> <ISWebGrid:WebGridRowLayout ColumnMember="[set your Mob.No column member in here]" /> </Layout> </ISWebGrid:WebGridColumnSet> <ISWebGrid:WebGridColumnSet Caption="ID Mo." ColumnCount="1" Name="ColumnSet3" Width="100px"> <Layout> <ISWebGrid:WebGridRowLayout ColumnMember="[set your Id.Mo column member in here]" /> </Layout> </ISWebGrid:WebGridColumnSet> </ColumnSets> <ColumnSetSettings RowCount="1" ShowHeaders="Yes" /> </RootTable> </ISWebGrid:WebGrid>
Result:
Hope this helps.
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