ngGrid排序整个结果集 [英] ngGrid sort entire result set

查看:481
本文介绍了ngGrid排序整个结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想上的 ngGridSorted 事件进行排序整个结果集(不仅仅是页)由被点击排序功能。有没有一种简单的方法来做到这一点?我还没有看到如何排序任何东西,但该用户当前页面上的一个很好的例子。

I would like on the ngGridSorted event to sort the entire result set (not just the page) by the sort function that was clicked on. Is there an easy way to do this? I haven't seen a good example of how to sort anything but the page that the user is currently on.

推荐答案

其实你只可以使用服务器端分页选项,而不必实际serversided code。

In fact you just can use the server-side paging option without actually having serversided code.

有关下一代网演示的例子还只是加​​载一个大的JSON文件。

The example on the ng-grid demos also just loads a big json file.

您需要重写的功能是:

 $scope.getPagedDataAsync = function (pageSize, page, searchText)

不必加载就可以把逻辑在这里的文件具有搜索和拼接阵列的能力。

Instead of loading a file you can put logic in here that has the ability to search and splice an array.

没有必要做异步的东西只是因为功能有异步的名称中。

No need to do async stuff just because the function has async in its name.

使用数组操作函数库如罗短跑下划线是这里有很大的帮助。

A library with array manipulation functions like Lo-Dash or Underscore is of great help here.

更新:

因为我发现,演示不包括排序(DOH!)我给你做这个的 Plunker 这是官方服务器的扩展版本片面分页演示,内有排序和非服务器阵列。

Since I found out that the demo doesn't include sorting (Doh!) I made you this Plunker which is an extended version of the official server sided Pagination demo that also features sorting and a non server array.

在code是一个有点复杂。看看你是否理解,还是回来与提问。

The code is a bit complex. See if you understand it, or come back with questions.

排序算法不是很优化。事实上,我把它从<一个href=\"http://stackoverflow.com/questions/8837454/sort-array-of-objects-by-single-key-with-date-value\">here (再次感谢,大卫!)

The sorting Algorithm is not very optimized. In fact I took it from here (Thanks again, David!)

这篇关于ngGrid排序整个结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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