[RESOLVED]Order groups in JQGrid

I have the below data

Category Order Item
A 3 ITM1
B 1 ITM2
C 2 ITM3

I want to display this data in JQGrid as below  

  Item
B  
  ITM2
C  
  ITM3
A  
  ITM1

Hi Kalyan,

You could use the JQGridSortEventArgs passed to the Sorting event to detect the column being sorted and the sort direction. Here is an example of overridiing the default sorting logic:

<trirand:JQGrid runat="server" ID="JQGrid1" Width="600px" OnSorting="CustomSortingGrid_Sorting">

protected void CustomSortingGrid_Sorting(object sender, Trirand.Web.UI.WebControls.JQGridSortEventArgs e)
{
    // Cancel the default sorting, which essentially sorts the clicked column
    e.Cancel = true; 

    // Get data from the datasource
    DataTable dt = GetData(); 
    // Set sorting to always sort using the ID column
    // You can change that using the event arguments e.SortExpression (column name) and 
    // e.SortDirection (asc / desc)
    dt.DefaultView.Sort = "CustomerID " + e.SortDirection.ToString().ToUpper();            

    // Rebind the grid using the sorted DataTable
    JQGrid1.DataSource = dt;
    JQGrid1.DataBind();
}

More details, please refer

http://www.trirand.net/documentation/aspnet/_2s90o9ffz.htm

Besides, here are some similar threads, perhaps they can helps you.

JQGrid – SortCol Not Working.

JqGrid Searching, Sorting, Paging,
Freejing, Coulmn Show Hiding with…

Best Regards,
Dillion

Leave a Reply