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_Related Related Topics sp_TopicIcon
Proper way to page jqGrid
09/01/2013
17:42
Avatar
popsovy
Member
Members
Forum Posts: 6
Member Since:
12/12/2011
sp_UserOfflineSmall Offline

I need to display a number of "dynamic" grids using jqGrid. By dynamic I mean that both definition and data of the grid are retrieved from a database. There are many grids on the page, so I am trying to minimize the number of server trips, and there is a lot of data, so server-side paging is a must.

My workflow is

  • On initialization of each grid, retrieve grid definition and first page of data in one server call.
  • If a user sorts/pages, then retrieve a page of data from the server

Because I want to retrieve the grid definition and first page of data in one call, I cannot use datatype: 'json', url: '###' approach; instead I do:

grid.jqGrid({

    mtype: 'post',

    …       

    datatype: function (postdata) {

        if (!init.data) {

            var request = {

                screenId: settings.screenId,

                pageNumber: postdata.page,

                pageSize: postdata.rows,

                sortColumn: postdata.sidx,

                sortDirection: postdata.sortd,

                date: settings.date

            };

            site.callWs("/MyService", request, function (pageResponse) {

                //WHAT TO CALL HERE TO SET A PAGE OF DATA?

            });

        } else {

            //WHAT TO CALL HERE TO SET A PAGE OF DATA?

            init.data = null;

        }

    }

});

My data object (pageResponse or init.data) looks like this

Data PageImage Enlarger

I am not sure what method to call on jqGrid once a page of data is returned. I considered addJSONData, but it seems so inefficient to convert JSON back to string, then use EVAL(). Also, considered addRowData or setting the data property, but I am confused how to instruct jqGrid that I am doing server-side paging — if I set the data property to one page of records, what do I need to do to tell jqGrid that there is a total of 50 records and this is page 1 out of 10.

Thanks for your help

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
37 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