【问题标题】:Issue with the Navigation Bar in jqGridjqGrid中的导航栏问题
【发布时间】:2012-04-23 06:26:23
【问题描述】:

我的 jqGrid 配置有问题。我正在尝试使用此配置激活导航栏:

$(function(){ 
    $("#list").jqGrid({
        url:'test.xml',
        datatype: 'xml',
        mtype: 'GET',
        colNames:['Name','Last Name', 'Id Nbr'],
        colModel :[ 
           {name:'name', index:'name', width:200}, 
           {name:'lastName', index:'lastName', width:200}, 
           {name:'idnbr', index:'idnbr', width:60}
        ],
        pager: '#pager',
        rowNum:10,
        rowList:[10,20,30],
        sortname: 'name',
        sortorder: 'desc',
        viewrecords: true,
        gridview: true,
        loadonce: true,
        sortable: true,
        rownumbers: true,
        height: '100%',
        width: '800',
        caption: 'My first grid'
    }); 
}); 
jQuery("#list").jqGrid('navGrid','#pager',{edit:true,add:true,del:true});

我的 HTML 代码如下所示:

<table id="list"><tr><td/></tr></table> 
<div id="pager"></div> 

我在 Stackoverflow 上阅读了很多关于如何配置导航栏的答案,但我无法在栏中获得我的添加、编辑、删除、查找和刷新按钮,只有页面句柄。

我想知道我的代码是否遗漏了什么,因为我已经尝试获取此按钮但直到现在还没有结果。

提前感谢您的帮助

【问题讨论】:

    标签: jqgrid navigation


    【解决方案1】:

    错误是您调用navGrid 在$(function(){/*it should be here*/}); 之外。因此,该方法不仅会在创建网格之前被调用,而且可能会在&lt;table&gt; 和&lt;page&gt; 元素被放置(加载)到页面上之前发生事件。

    只需将navGrid 的调用移到$(function(){/*it should be here*/}); 的上方一行(与$(document).ready(function () {/*the same code inside*/}) 相同,请参阅jQuery.ready),您的代码就会按预期运行。

    【讨论】:

    • 嗨,奥列格。感谢您的答复。实际上,我已经让我的网格工作了,按钮终于在导航栏上!再次感谢
    • 我实际上已经在 IE8 上测试了我的网格,但 Navgrid 给了我一些问题(网格消失了)。如果我删除所有的 navGrid,我的网格会再次出现在我的页面上,但如果我离开 navGrid 选项,它仍然会消失。在 IE 中调试后,我意识到我有一个 JS 错误。修复后,寻呼机出现,但导航栏的图标消失了。您知道为什么会发生这种情况吗?谢谢
    • 好吧,看来使用标签&lt;meta http-equiv="X-UA-Compatible" content="IE=8" /&gt; 效果很好。无论如何,这是问题的真正解决方案吗?谢谢
    • @ABottoni:上次我尝试在我的演示中始终包含 &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt; 以确保 IE 兼容模式不会干扰(请参阅 cmets 到 the answer)。为了确定这是否是您问题的真正解决方案,我必须查看(重现)问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 2016-10-25
    • 1970-01-01
    • 2018-06-19
    • 2021-04-04
    相关资源
    最近更新 更多