对KendoGrid数据源进行排序。 [英] Sorting a KendoGrid Data Source.

查看:398
本文介绍了对KendoGrid数据源进行排序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个像剑道网格一样的要求,我必须做两件事



1.获取KendoGrid数据。

2.获取数据源后,我必须对该数据源中的一些行进行排序。





我得到的数据源如



Hello,

I have a requirement like I have on Kendo Grid and and I have to do two things with that

1.Getting KendoGrid datasorce.
2.After getting the datasource I have to sort some of the rows in that data source.


I am getting the datasource like

var dataSource = $("#" + gridId).data().kendoGrid.dataSource.data();





但是我无法按任何方式排序



我用以下过程来做这件事





but I am not able to sort it any way

I have used the following process to do that

dataSource = new kendo.data.DataSource({
            data: dataSource,
            sort: { field: "Column1", dir: "desc" }
        });

        dataSource = dataSource.view();





但这是最糟糕的尝试。



等待回复。



谢谢

Ipsita



But it was worst trying.

Waiting for the reply.

Thanks
Ipsita

推荐答案

+ gridId).data()。kendoGrid .dataSource.data();
("#" + gridId).data().kendoGrid.dataSource.data();





但是我无法按任何方式排序



我使用了以下过程来执行此操作





but I am not able to sort it any way

I have used the following process to do that

dataSource = new kendo.data.DataSource({
            data: dataSource,
            sort: { field: "Column1", dir: "desc" }
        });

        dataSource = dataSource.view();





但这是最糟糕的尝试。



等待回复。



谢谢

Ipsita



But it was worst trying.

Waiting for the reply.

Thanks
Ipsita


我从网格上看到获取Kendo数据源的方式是这样的:

The way I've seen to get a Kendo DataSource from a Grid is like this:
var ds =


#grid)。 data( kendoGrid)。dataSource;
("#grid").data("kendoGrid").dataSource;



一旦你在变量中有了DataSource,就可以在它上面运行.sort()并传入一个排序对象:


Once you have the DataSource in a variable, you can simple run .sort() on it and pass in a sort object:

ds.sort({ field: "fieldName", dir: "asc" });


这篇关于对KendoGrid数据源进行排序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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