【问题标题】:jqGrid Pager icons not showing upjqGrid寻呼机图标不显示
【发布时间】:2014-02-14 17:27:36
【问题描述】:

我阅读了有关此问题 Stack 的其他几篇帖子,但无法找到解决方案。这是我的html的链接。我是否缺少任何 CSS 或其他内容?

<script src="jquery/jquery-1.4.1.min.js"></script>
<script src="jquery/jquery-1.4.1.js"></script>

<!-- jqGrid -->
<link rel="stylesheet" type="text/css" href="jqGrid/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" href="jqGrid/jquery-ui-custom.css" />
<script src="jqGrid/grid.locale-en.js" type="text/javascript"></script>
<script src="jqGrid/jquery.jqGrid.min.js" type="text/javascript"></script>

我正在测试的代码只是 jqGrid 站点中示例的副本。

 $(document).ready(function (event) {

  jQuery("#listArray").jqGrid({
    datatype: "local",
    height: 100,
    colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
    colModel: [
        { name: 'id', index: 'id', width: 60, sorttype: "int" },
        { name: 'invdate', index: 'invdate', width: 90, sorttype: "date" },
        { name: 'name', index: 'name', width: 100 },
        { name: 'amount', index: 'amount', width: 80, align: "right", sorttype: "float" },
        { name: 'tax', index: 'tax', width: 80, align: "right", sorttype: "float" },
        { name: 'total', index: 'total', width: 80, align: "right", sorttype: "float" },
        { name: 'note', index: 'note', width: 150, sortable: false }
    ],
    multiselect: false,
    caption: "Manipulating Array Data",
    rowNum: 6,
    rowList: [3, 6, 9],
    pager: '#jqPager',
  });

  var mydata = [
        { id: '1', invdate: '2007-10-01', name: 'test', note: 'note', amount: '200.00', tax: '15.37', total: '210.89' },
        { id: "2", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
        { id: "3", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
        { id: "4", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
        { id: "5", invdate: "2007-10-05", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
        { id: "6", invdate: "2007-09-06", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
        { id: "7", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
        { id: "8", invdate: "2007-10-03", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
        { id: "9", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" }
        ];

  for (var i = 0; i <= mydata.length; i++) {
    jQuery("#listArray").addRowData(i + 1, mydata[i]);
  }

另一件事是页码无法正常工作。当我第一次加载页面时,它将显示第 1 页,共 0 页。当我单击“每页记录数”框以更改为默认值以外的内容时,页码将正确更新。有没有办法修复它,以便在页面加载时页码将显示正确的第 1 页,共 2 页?

谢谢!

【问题讨论】:

  • 你有“navGrid”的代码吗?另见类似问题:stackoverflow.com/questions/3491963/…
  • 谢谢!该链接帮助我解决了分页问题。不知道添加这些行后我必须重新加载网格。
  • 很高兴能帮到你:)

标签: javascript jquery html css jqgrid


【解决方案1】:

对我来说,这是 .png 文件没有被拾取的情况。在 jquery-ui.css 中,通过将 ../ 放在前面来更改您的相对引用,例如 images/xxxxx.png 变为 ../images/xxxxxx.png

【讨论】:

    【解决方案2】:

    我在您的代码中发现了一些语法错误,并根据您的本地数据更正了一些逻辑。这对我来说很好。我已将您的 localdata 直接添加到 jqgrid 中。像这样,

    datatype: "local",
    height: 'auto',
    data : mydata,
    

    你的 html 可能看起来像这样,

    <table id="listArray">
    <tr>
        <td />
    </tr>
    </table>
    <div id="jqPager"></div>
    

    当然你需要添加 navGrid 部分。像这样,

     $("#listArray").jqGrid('navGrid', '#jqPager', 
               { edit: false, add: false, del: false });
    

    这是您的代码的Demo。希望这会有所帮助。

    【讨论】:

    • 谢谢!这真的帮助我弄清楚缺少什么。我使用您使用的 Google CSS 文件解决了这个问题。 navGrid 真的很酷,但它只在我这边工作了一半。我完全复制了您的代码,但“查找”按钮没有像您的演示那样正确查找搜索。任何想法为什么?
    • 不客气。如果您觉得有用,请将其标记为答案。你的意思是在你的网格中找到按钮?
    • 是的,查找记录按钮。它仅适用于某些字段,例如数字,但不适用于文本字段。它也不适用于“Inv No”字段。
    • 你能告诉我你在Fiddle中的更新代码吗?所以我可以检查一下。
    • 我刚刚想通了。我使用的是最初包含在此文件中的 jQuery (v1.4)。我将链接升级到 1.9.1,它现在可以工作了。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多