Why are some rows disappearing when I sort or filter listjs table

南楼画角 提交于 2020-01-05 12:17:39

问题


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.


回答1:


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"});


来源:https://stackoverflow.com/questions/26953246/why-are-some-rows-disappearing-when-i-sort-or-filter-listjs-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!