How do you selectively disable a sort in C1GridView?

Posted by: hirom on 10 September 2017, 11:38 am EST

  • Posted 10 September 2017, 11:38 am EST

    We are in the process of upgrading the Grid from C1WebGrid to C1GridView.

    I have a question about disabling sort on certain column in the Grid. In the C1WebGrid, setting the SortExpression to empty string disabled the sort on that column, but in C1GridView, it does not work.

    How do you selectively disable a sort in C1GridView?

  • Replied 10 September 2017, 11:38 am EST

    Hi,


    the required technique is illustrated below:


    void C1GridView1_Sorting(object sender, C1GridViewSortEventArgs e)


    {


     if (e.SortExpression == "UnsortableColumn")


     {


       e.Cancel = true;


     }


    }

  • Replied 10 September 2017, 11:38 am EST

    Your code will just cancel the sorting from code behind, but I don’t even want to fire a call to code behind and also the cursor should stay as a pointer for non sortable column. This was doable in C1WebGrid by setting the SortExpression to empty string. Also in the Microsoft GridView if you do not specify the SortExpression it also disable the Sorting on that column I believe.

  • Replied 10 September 2017, 11:38 am EST

    We fixed the issue causing sorting not disabled if the SortExpression is set to empty string, the fix will be available with the next release.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels