为什么排序或过滤List.js表时某些行消失了 [英] Why are some rows disappearing when I sort or filter listjs table

查看:111
本文介绍了为什么排序或过滤List.js表时某些行消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Web应用程序,该应用程序可以从geojson文件读取,也可以从Google Fusion Tables中读取.

geojson在应用程序中可以正常工作,该应用程序将每个项目添加到地图中,也可以将其添加到表中的行中以进行搜索,排序和过滤.但是我遇到了一个奇怪的问题,我在诊断时遇到了麻烦,即添加行的位置,但是我认为listjs组件无法正常运行.

我被困住了,需要一些帮助!

以下是页面: http://alexgleith.github.io/SSSPros/

代码如下: https://github.com/alexgleith/SSSPros

请查看asset/js/app.js中的144至230行,该行用于设置图层,设置表格,然后向Google Fusion Tables发出请求.

如果我还不够清楚,请提出问题.

总而言之,在示例Web应用程序中,地图和表格中有六个项目.如果您对表进行排序或过滤,其中两个将消失.我不知道为什么.

解决方案

请参见第352行,其中在 注册jQuery ajaxStop处理程序后创建列表.这应该等到AJAX调用完成创建列表之后,但是您的Fusiontables功能没有正确添加到列表中.如果您在页面加载后在JavaScript控制台中手动运行以下命令,则会看到列表已创建并正确排序:

featureList = new List("features", {valueNames: ["feature-name"]});
featureList.sort("feature-name", {order:"asc"});

I'm writing a webapp that reads from a geojson file and also out of Google Fusion Tables.

The geojson works fine in the app, which adds each item to a map and also as a row in a table for searching, sorting and filtering. But I'm having a strange issue that I'm having trouble diagnosing, where the rows get added, but I think the listjs components aren't functioning properly.

I'm stuck, and need some help!

Here's the the page: http://alexgleith.github.io/SSSPros/

Here's the code: https://github.com/alexgleith/SSSPros

Look at lines 144 to 230 in assets/js/app.js, which sets up the layer, sets up the table, and later, does a request to Google Fusion Tables.

Please ask questions if I haven't been clear enough.

To summarise, in the example webapp, there are six items on the map and in the table. IF you sort or filter the table, two of them disappear. I don't know why.

解决方案

See line 352 where the list is created after the jQuery ajaxStop handler is registered. This should wait until after the AJAX calls have finished to create the list, but your fusiontables features are not being properly added to the list. If you manually run the following commands in your JavaScript console after the page has loaded, you will see the list is created and sorted properly:

featureList = new List("features", {valueNames: ["feature-name"]});
featureList.sort("feature-name", {order:"asc"});

这篇关于为什么排序或过滤List.js表时某些行消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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