可以slickgrid页面并显示json
我们希望在请求页面时向客户端加载数千条记录,并显示前 25 条记录。然后,用户应该能够翻阅记录或按列重新排列列表或按各列中的数据进行过滤。我们选择一次性将数据加载到客户端,因为我们希望页面请求负载更重,并在之后查看或编辑数据时获得更快的性能。我在 SlickGrid 网站上看不到任何分页示例。 SlickGrid 是否内置了分页功能,或者它是如此轻量级,我必须自己实现它?有没有人有任何链接或示例可以分享,可以让我领先?
我们将使用的数据将是 json 数据。
We want to load several thousand records to the client when the page is requested and have the first 25 records displayed. The user should then be able to page through the records or resort the list by column or filter by data in various columns. We're opting to load the data to the client in one lump sum because we'd rather have a heavier load in the page request and faster performance when viewing or editing data after. I can't see any example for paging on the SlickGrid site. Does SlickGrid have paging baked in or is it so lightweight I'd have to implement this myself? Does anyone have any links or examples to share that would give me a headstart?
The data we'll be using will be json data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
SlickGrid/slick.dataview.js 中有分页支持,
您还需要在页面上的某个位置进行渲染。
There is paging support in SlickGrid/slick.dataview.js
You will also want somewhere on your page for it to render.
我编写了一个分页器插件,SlickGrid 增强分页器,它使 SlickGrid 分页使用起来更加容易。完全支持json。请参阅 github 上的这个项目。
I have written a pager plugin, the SlickGrid Enhancement Pager, that makes SlickGrid pagination use much easier. It fully supports json. Please see this project on github.
在上面设置排序器
In the above set the sorter
这也让我困惑了一段时间,直到我让下面的代码起作用:
This puzzled me for a while too, until I got the code below to work:
我已经用 slickgrid 编码大约一周了,发现我必须自己编写排序和过滤代码。查看源代码,我没有看到任何表明分页是内置的。您将花费大量时间为其编写代码,但这似乎是值得的。
我使用 ajax/json 加载了 30,000 行数据,加载和排序时间不到 1 秒。我不知道这是否有任何帮助,但这是我调用来加载网格的方法。它在客户端排序并在服务器上过滤:
当调用排序方法时,绑定到网格(数据)的数组将被重新排列,然后使用 .render() 方法重新加载网格。为了进行分页,您必须拥有一个包含所有数据的数组和一个显示数据的数组。
他确实有一个分页示例 这里,但作为 javascript 业余爱好者,我是的,我很难跟上。
I've been coding with slickgrid for about a week now and found that I had to write sort and filter code myself. Looking through the source, I don't see anything that indicates paging is built in. You'll spend a good amount of time writing code for it, but it seems to be worth it.
I loaded 30,000 rows of data using ajax/json and it loads and sorts in less than 1 second. I don't know if it will be any help, but this is the method I call to load my grid. It sorts on the client and filters on the server:
When the sort method is called, the array bound to the grid (data) is rearranged, and then the grid is reloaded using the .render() method. In order to page, you'll have to have an array of all data, and an array of displayed data.
He does have an example of paging here, but being the javascript amateur I am, it's difficult for me to follow.