jsGrid - 获取用户在搜索 navGrid 中输入的数据

jsGrid - get data typed by the user in a search navGrid

我正在尝试使用 d3 和 jqGrid 库绑定 table 和图形。为此,我必须让用户在搜索框中键入搜索(我的 table 看起来像这样:http://www.guriddo.net/demo/guriddojs/

我找到了这个函数: grid.getGridParam("postData").过滤器 但我不知道如何使用它。我考虑过触发事件 "jqGridToolbarAfterSearch" 以在每次搜索后获取数据,但似乎不起作用... 如果有人有想法,我将不胜感激! 谢谢

Ps : 如果存在相同的方法来设置数据,我也很感兴趣

希望我正确理解了你的问题。我假设您首先将 the demo 的 CSV 数据转换为更多大陆数据格式:具有某些属性的项目数组(nameeconomycylindersdisplacementpowerweightmphyear)。然后你可以使用 datatype: "local"data 作为输入数据。我假设用户应用了 local 过滤器,然后您想获取过滤后的数据

如果你使用free jqGrid fork of jqGrid (it's the fork which I develop) then you can get lastSelectedData parameter (var filteredData = $grid.jqGrid("getGridParam", "lastSelectedData");) to have the array of filtered items (see the demo)。之后,您可以将 d3 与过滤后的项目一起使用。