JimC
JimC

Reputation: 99

jqGrid Pager icons not showing up

I read through several of the other posts on this issue Stack and was unable to find a solution. Here are the links for my html. Am I missing any CSS or something?

<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>

The code I'm testing out is just a copy of the example from the jqGrid site.

 $(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]);
  }

The other thing is that the Page Number doesn't work correctly. When I first load the page, it will show Page 1 of 0. When I click on the Records per Page box to change to something other than the default, the Page Number will update correctly. Is there a way to fix it so that the Page number will show the correct Page 1 of 2 when the page loads?

Thanks!

Upvotes: 1

Views: 3752

Answers (2)

Mike Hart
Mike Hart

Reputation: 121

For me it was a case of the .png files not getting picked up. In the jquery-ui.css change your relative reference by putting ../ in the front for example images/xxxxx.png becomes ../images/xxxxxx.png

Upvotes: 2

Vinoth Krishnan
Vinoth Krishnan

Reputation: 2949

I have found some syntax errors in your code and corrected few logic's based on your local data. Which is working fine for me. I have added your localdata into jqgrid directly. Like this,

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

And your html may look like this,

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

Of course you need to add navGrid part. Like this,

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

This is working Demo of your code. Hope this helps.

Upvotes: 0

Related Questions