在多列上排序剑道网格 [英] Sorting kendo grid on multiple columns

查看:78
本文介绍了在多列上排序剑道网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个剑道网格.页面加载时,默认情况下,我想按列1依次然后按列2降序对网格进行排序.

i have a kendo grid. When the page loads, by default i want to sort the grid by column1 then by column2 in descending order.

问题: 它的排序符合预期,但是排序箭头显示在最后一个排序的列上.因此,在以下情况下,当页面加载时,排序箭头位于"DueDate"上,而不是"DownloadDate"上

Issue: Its sorting as expected however sort arrow shows up on last sorted column. So in the case below when the page loads the sort arrow is on "DueDate" instead of "DownloadDate"

 @(Html.Kendo().Grid<TrackingVM>()
    .Name("Grid")
    .Columns(col =>
    {
        col.Bound(p => p.ID).Hidden();
        col.Bound(p => p.Year);
        col.Bound(p => p.State);                        
        col.Bound(p => p.DueDate).Format("{0:MM/dd/yyyy}");
        col.Bound(p => p.DownloadDate).Format("{0:MM/dd/yyyy}");            
    })
    .AutoBind(false)
    .Pageable(x => x.PageSizes(UISettings.PageSizes))
    .Sortable(x => x.AllowUnsort(false))
    .Resizable(resizing => resizing.Columns(true))
    .Scrollable(s => s.Height("auto"))
    .DataSource(dataSource => dataSource
        .Ajax()            
        .Sort(x => x.Add(y=>y.DownloadDate).Descending()).Sort(x=>x.Add(y=>y.DueDate).Descending())
        .Read(read => read
            .Action("GetData", "Tracking"))
    .ServerOperation(false))
)

推荐答案

您当前添加列进行排序的方式基本上会覆盖前一列,并且仅考虑您编写的最后一列(在这种情况下为DueDate ).发生这种情况是因为您的.Sort()是作为一个语句编写的.

The way you're currently adding columns to sort basically overrides the previous column and only takes into account the last column that you write (DueDate in this case). This happens because your .Sort() is written as one single statement.

要使排序正常进行,您应将.Sort()更改为:

To get your sorting to work properly you should change your .Sort() to:

.Sort(x =>
{
    x.Add(y=>y.DownloadDate).Descending());
    x.Add(y=>y.DueDate).Descending());
} 

这篇关于在多列上排序剑道网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆