Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Unable to get paging working.
08/04/2010
01:42
Avatar
dash
Member
Members
Forum Posts: 4
Member Since:
08/04/2010
sp_UserOfflineSmall Offline

Hi,

I add paging to books sample and it works just fine without the 'page', 'total', and 'records' parameters. 

<table id="booksGrid"></table>

<div id="booksPager"></div>

jQuery("#booksGrid").jqGrid({

url: 'BooksGrid',

datatype: "xml",

colNames:["Author","Title", "Price", "Published Date"],

colModel:[

{name:"Author",index:"Author", width:120, xmlmap:"ItemAttributes>Author"},

{name:"Title",index:"Title", width:180,xmlmap:"ItemAttributes>Title"},

{name:"Price",index:"Manufacturer", width:100, align:"right",xmlmap:"ItemAttributes>Price", sorttype:"float"},

{name:"DatePub",index:"ProductGroup", width:130,xmlmap:"ItemAttributes>DatePub",sorttype:"date"}

],

height:250,

rowNum:10,

rowList:[10,20,30, 40],

viewrecords: true,

loadonce: true,

pager: '#booksPager',

multiselect: true,

xmlReader: {

root : "Items",

row: "Item",

repeatitems: false,

id: "ASIN"

}

});

// even though the data contains only 2 items, the paging works ok. 

<?xml version="1.0" encoding="UTF-8"?><Books> <Items> <Request> <IsValid>True</IsValid> <ItemSearchRequest> <SearchIndex>Books</SearchIndex> </ItemSearchRequest> </Request> <Item> <DetailPageURL></DetailPageURL> <ItemAttributes> <Author>John Grisham</Author> <Title>A Time to Kill</Title> <Price>12.99</Price> <DatePub>1998-05-01</DatePub> <ASIN>0446351230</ASIN> </ItemAttributes> </Item> <Item> <DetailPageURL></DetailPageURL> <ItemAttributes> <Author>Stephen King</Author> <Title>Blood and Smoke</Title> <Price>24.00</Price> <DatePub>2000-01-01</DatePub> <ASIN>0446355453</ASIN> </ItemAttributes> </Item> </Items></Books>

But, I can't get paging working on the similar code below.  I get 'b.jgrid.formatter.integer' is null or not an object error.  I also tried adding page, total, and records, that mentioned in other help topics, but the same error occurs.  Any help is greatly appreciated.

// js includes

<link rel="stylesheet" type="text/css" media="screen" href="jQuery/themes/redmond/ui.all.css" />

 

<link rel="stylesheet" type="text/css" media="screen" href="/jQuery/themes/jqGrid/ui.jqgrid.css" />

 

 

<script src="jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>

 

<script src="jQuery/grid.locale-en.js" type="text/javascript"></script>

<script src="jqGrid-3.6.4/jquery.jqGrid.min.js" type="text/javascript"></script>

// jqGrid code

<table id="groupsGrid"></table>

<div id="groupsGridPager"></div>

$(document).ready(function () {

$("#groupsGrid").jqGrid({

url: 'getGroups.do',

datatype: "xml",

colNames:["Name", "Description", "Default", "Modify", "Delete"],

colModel:[

{name:"Name", index:"Name", width:150, align:"center", xmlmap:"name"},

{name:"Description", index:"Description", width:150, align:"center", xmlmap:"description"},

{name:"IsDefault", index:"IsDefault", width:40, align:"center", formatter:yesNoFormatter, xmlmap:"isDefault"},

{name:"EditImage", index:"EditImage", width:110, align:"center", formatter:editImageFormatter},

{name:"DeleteImage", index:"DeleteImage", width:110, align:"center", formatter:deleteImageFormatter}

],

rowNum: 10,

rowList:[10,20,30],

viewrecords: true,

autowidth: true,

height: "auto",

altRows: true,

loadonce: true,

pager: '#groupsGridPager',

multiselect: true,

loadtext: 'Loading groups...',

xmlReader: {

root : "groups",

row: "group",

repeatitems: false,

id: "[id]"

}

});

});

 

// data

<?xml version="1.0" encoding="utf-8"?>
<groups>
  <group id="1">
    <name>Accounting</name>
    <description>Accounting Department</description>
    <isDefault>1</isDefault>
  </group>
  <group id="2">
    <name>Dev</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="3">
    <name>Finance</name>
    <description>Finance Department</description>
    <isDefault>0</isDefault>
  </group>
  <group id="4">
    <name>Group3</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="5">
    <name>Group4</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="6">
    <name>HR</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="7">
    <name>aa</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="8">
    <name>abc</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
</groups>

12/04/2010
10:13
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Where and how you try to add the additional parameters like page and etc.

Note the if you define them below the groups tag, the xmlReader should cnow this.

Suppose you have

...

<groups>

<total>1</total>

...

</grops>

The the xmlReader should look like this

xmlReader :{

...

total: "groups>total",

..

}

Hope you got the point.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

12/04/2010
17:37
Avatar
dash
Member
Members
Forum Posts: 4
Member Since:
08/04/2010
sp_UserOfflineSmall Offline

hi tony,

thanks for your response.  i did add the pagination data in the response xml last week, but the pagination still wasn't working properly.  the weird thing was i kept getting " '$.jgrid.formatter.integer' is null or not an object" error from updatepager in grid.base.js in the dev version once i enabled the pager.  the offending line is.

if(pgboxes) {
                fmt = $.jgrid.formatter.integer || {};

In the min version, i'd to make the following change to suppress the js error in order to work on other features such as add, edit, etc. as well as the pager.

from: if(o){r=b.jgrid.formatter.integer||{};

to: if(o){r=b.fmatter||{};

After modifying the code in the min version and setting the 'loadonce' to false, the row list drop down did make an ajax call to the server; however, record text, page text still didn't show up.  i really don't know what the side effect might be by blindly changing the core code.  i shouldn't need to modify the core library for the pager to work properly, should i?

i've been stuck on this feature for almost a week.  any help will be greatly appreciate.  please see the latest code below.

thanks again for your help,

dash

p.s. how's life in sofia? i was there couple weeks, working with folks at sciant, an outsourcing dev firm, in 03/04.  you might even know some guys working there back then.  sciant was acquired by vmware a few years back.  i'm sure sofia also has got a complete facelift since then...

$(document).ready(function () {

        $("#groupsGrid").jqGrid({
            url: 'getGroups.do',
            datatype: "xml",
               colNames:["Name", "Description", "Default"],
               colModel:[
                   {name:"Name", index:"Name", width:150, align:"center", xmlmap:"name", editable:true, editoptions:{size:20}},
                   {name:"Description", index:"Description", width:150, align:"center", xmlmap:"description", editable:true, editoptions:{size:30}},
                   {name:"IsDefault", index:"IsDefault", width:40, align:"center", formatter:yesNoFormatter, xmlmap:"isDefault", editable:true, edittype:"checkbox", editoptions:{value:"Yes:No"}}
               ],
               pager: $('#groupsGridPager'),
            pginput: true,
               rowNum: 5,
               rowList: [5,10,15],
               sortorder: "asc",
            sortname: "Name",
            viewrecords: true,
            autowidth: true,
            height: "auto",
            altRows: true,
            loadonce: false,
            multiselect: true,
            loadtext: 'Loading groups...',
            xmlReader: {
                    root : "groups",
                    row: "group",
                    repeatitems: false,
                    page: "groups>page",
                    total: "groups>total",
                    records:"groups>records",
                    id: "[id]"
            }
        });

// xml

<?xml version="1.0" encoding="utf-8"?>

<groups>
  <page>1</page>
  <total>3</total>
  <records>12</records>
  <group id="1">
    <name>Accounting</name>
    <description>Accounting Department</description>
    <isDefault>1</isDefault>
  </group>
  <group id="2">
    <name>Dev</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="3">
    <name>Finance</name>
    <description>Finance Department</description>
    <isDefault>0</isDefault>
  </group>
  <group id="4">
    <name>Group4</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>
  <group id="5">
    <name>Group5</name>
    <description>Created to test the createGroup feature</description>
    <isDefault>0</isDefault>
  </group>

</groups>

14/04/2010
21:08
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Just copy paste your example in my demo and it works just fine.

The reason for

fmt = $.jgrid.formatter.integer || {}; is undefined is:

You do not have loaded the language file correct (grid.locale-en.js)

1. Ensure that this file is loaded

2. Ensure that it is loaded before jqGrid js file.

Best Regards

Tony

Edit: It seems like this

<script src="jQuery/grid.locale-en.js" type="text/javascript"></script>

does not load the lang file.

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
64 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information