Sorting Boolean Column in Grid

2 posts, 0 answers
  1. Brian
    Brian avatar
    17 posts
    Member since:
    Aug 2015

    Posted 27 Mar 2018 Link to this post

    Hi,

    I have a grid which has a column bound to a boolean value indicating if the record is a priority or not.

    I wan't to be able to sort the grid so that records with priority set to true to be at the top.

    I cannot find any way to do this in the docs, is it possible? I notice that even the default sorting does not work (by clicking the header) so trying to set a sort order on the DataSource model is just failing on page load.

    This is the child grid in a hierarchical situation if that makes any difference...

     

    .Sort(s =>
    {
    s.Add(m => m.Priority).Ascending();
    s.Add(m => m.Start).Descending();
    }))
     
    columns.Bound(m => m.Priority).Filterable(false).ClientTemplate("\\#= Priority ? '" + Resources.BUTTON_YES + "' : '" + Resources.BUTTON_NO + "' \\#")
  2. Stefan
    Admin
    Stefan avatar
    2893 posts

    Posted 28 Mar 2018 Link to this post

    Hello, Brian,

    Thank you for the details.

    The provided code is the supported approach to sort the Grid column initially.

    Also, if the Grid is sortable, the user should be able to sort it manually:

    https://docs.telerik.com/aspnet-mvc/helpers/grid/configuration#sort

    Could you please check if there are any errors in the console?

    Additionally, then this should work in the same way if the Grid is a child Grid.

    If possible, please provide a runnable example as the could be caused by a factor which we are overlooking at this moment.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top