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
jqGrid loadonce problem
26/08/2009
06:03
Avatar
marko999
Belgrade
New Member
Members
Forum Posts: 1
Member Since:
26/08/2009
sp_UserOfflineSmall Offline

hi all, I am using jqGrid with asmx web services…because services need to be called on specific way, I am using datatype parameter as a function call in which I am calling web service using jquery $.ajax method

Here is my code:

datatype: function() {
                    $
.ajax({
                        url
: 'Default.aspx/GetPersons',
                        data
: “{}”,
                        type
: “POST”,
                        dataFilter
: function(data) {
                           
var msg = eval('(' + data + ')');
                           
if (msg.hasOwnProperty('d'))
                               
return msg.d;
                           
else
                               
return msg;
                       
}

everything works fine, I am getting json from the server and grid display
everything as suppose to. But, from some strange reason,
I can't accomplish sorting on client via loadonce: true attribute, for
every event on grid, grid calls server...

Any ideas how to solve this?

cheers

Marko

30/08/2009
09:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

loadonce work only with the predefined loaders. If you use datatype as function you should set datatype:local manually after the first loading of the grid with the custom function. Something like:

datatype : function (){

$.ajax({

...

complete :function (...){

.....

$("#mygrid").setGridParam({datatype:'local'});

}

})

},

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.

13/02/2010
02:02
Avatar
mdmangus
Texas
New Member
Members
Forum Posts: 1
Member Since:
13/02/2010
sp_UserOfflineSmall Offline

I had the same need as the original poster.  Tony's reply shows the datatype needed to be set to local for the grid to sort client side.

I did the following that way I could have local sorting, but have ajax requests to be fired in other scenarios.

        //
        // loadGrid anonymous function
        var loadGrid = function(postdata) {
            … code ajax request, whatever..
        }

        $("#mygrid").jqGrid({
            datatype: loadGrid,
            rowNum: -1, // show all rows
            loadonce: true, // disabled paging and all sorting done locally
            … other jqGrid options,
            onSortCol: function(index, iCol, sortorder) {
                //
                // Grid loaded all records, so sort locally
                // Re-Wire datatype for ajax in Grid Complete
                $("#mygrid").setGridParam({ datatype: 'local' });
            },
            gridComplete: function() {
                //
                // Rewire datatype to ajax function
                if ($("#mygrid").getGridParam("datatype") === "local")
                    $("#mygrid").setGridParam({ datatype: loadGrid });
            }

With that in place your grid will switch to datatype: local when you click the sorting column and after completion it sets the grid back to the function that cotains your code and web service call.

Hope this helps others.

04/03/2010
10:00
Avatar
limasdf
New Member
Members
Forum Posts: 2
Member Since:
04/03/2010
sp_UserOfflineSmall Offline

mdmangus 's solution 100% work perfectly  thank you!


02/07/2010
23:38
Avatar
JeffV
California
Member
Members
Forum Posts: 7
Member Since:
30/06/2010
sp_UserOfflineSmall Offline

I'm not sure anyone is watching this thread anymore,

But when I made these changes when I click on the "Next" button I get an error stating:

J.toUpperCase is not a function

jquery.jqGrid.min.js

Line 19

complete :function (…){

…..

$("#mygrid").setGridParam({datatype:'local'});

}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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