是否可以将导航项添加到 jqGrid 中的“top pager”?如果是这样,这样做的语法是什么?
我的页面上有一个 HTML 片段,看起来像这样
<table id="mygrid">
</table>
<div id="mygrid_pager"></div>
然后是一个看起来像这样的 jqGrid 初始化
$('#mygrid').jqGrid({
..., //full config string removed for brevity,
pager:jQuery('#mygrid'),
toppager:true
});
$('#mygrid').jqGrid('navGrid', '#mygrid_pager'),{
'add':false,
'del':false,
'edit':false,
'search':false,
'refresh':false,
'cloneToTop':true,
}).navButtonAdd('',{...}); //config navbutton string for button removed for brevity
id 为#mygrid_toppager 的“top pager”会自动插入到页面中,但它的自定义按钮(出现在底部pager 上)不会出现。
我see that there's a "cloneToTop" option包含在 navGrid 中,但它的描述似乎令人困惑,我只能假设我用错了。
Clones all the actions from the bottom pager to the top pager if defined. Note that the navGrid can be applied to the top pager only. The id of the top pager is a combination of grid id and "_toppager"
我对该选项的理解是它将按钮添加到底部寻呼机,并将它们复制到顶部。然而,描述接着说“navGrid 只能应用于顶部寻呼机,这没有任何意义,因为你正在克隆它。Pont 是,我显然对 API 的方式有很深的误解应该使用。
如果有人能给我指出正确的方向(即使只是某个地方的工作示例),我将不胜感激。我更愿意通过官方 API 执行此操作,而不是 to clever DOM manipulation ,如 StackOverflow 上的其他地方所见。
最佳答案
OK,看来我找到了一个看起来更好的方法。这个想法是使用 navButtonAdd
和 "#list_toppager_left"
而不是 "#pager"
。
我修改了 old answer因此,一个自定义按钮与一个标准按钮一起添加到导航工具栏的顶部。顶部导航工具栏中的其他元素将被删除。结果看起来像
现场可以看到对应的demo here .
关于javascript - 将 jqGrid 自定义导航添加到顶部工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3929896/