This is a migrated thread and some comments may be shown as answers.

Sorting Boolean Column in Grid

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 27 Mar 2018, 06:59 AM

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 + "' \\#")

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Mar 2018, 07:08 AM
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.
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or