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
method mergeJSONData
22/01/2011
23:15
Avatar
AndzinSan
Member
Members
Forum Posts: 8
Member Since:
20/12/2010
sp_UserOfflineSmall Offline

Hi,

I am using jqgrid for loading huge table of datas, thousands of rows. But for better performance I wand to load this huge table only one time - when site is loaded, and then periodic check server for newly added records after user load this huge table, but only this new records, not all, and then merge first time loaded json object with newly loaded records.

So i modyfi grid.base.js file:

2line around 589 before this:

var p = $.extend(true,{

add this:

var updateJSON = {};

2line around 688 before this:

_index : {},

add this:

dataUpdateJSON : false,

2line around 1180 before this:

addJSONData = function(data,t, rcnt, more, adjust) {

add this:

mergeJSONData = function(data){if(ts.p.dataUpdateJSON == true){/*data = updateJSON.data;here you must write some code do merge data and updateJSON.data*/t = updateJSON.bDiv;rcnt = updateJSON.rcnt;npage = updateJSON.npage;adjust = updateJSON.adjust;lc = updateJSON.lc;pvis = updateJSON.pvis;ts.p.datatype = "json";addJSONData(data,t,rcnt,npage>1,adjust);if(lc) { lc.call(ts,data); }if (pvis) { ts.grid.populateVisible(); }if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";}data=null;endReq();}},

2line around 1630 (after edit previous it can by different) before this:

if(dt === "xml") { addXmlData(data,ts.grid.bDiv,rcnt,npage>1,adjust); }

add this:

if(ts.p.dataUpdateJSON === true) { updateJSON.data = data;updateJSON.bDiv = ts.grid.bDiv;updateJSON.rcnt = rcnt;updateJSON.npage = npage;updateJSON.adjust = adjust;if(lc) { updateJSON.lc = lc; };if(pvis) { updateJSON.pvis = pvis;};}

Ok, adding done, now edit your setup:

in your jqgrid set up new option "dataUpdateJSON" to true - default is false; true enable this little trick

dataUpdateJSON: true,

set up option loadComplete to function witch will call your custom reload grid function, example: reload_grid();

sample:

var grid_reload;

var grid_reload_time = 3000;

function reload_grid()

{

clearInterval(grid_reload);

grid_reload = setInterval(function()

{

var mygrid = jQuery("#grid")[0];

$.ajax( url:"your ajax url",

type:"POST",

dataType: "json" ,

data: "your data to server",

success:function(data,st)

{

mygrid.mergeJSONData(data);

});

},grid_reload_time);

};

WARNING: I test this only with my configuration:

loadonce: true,

rowTotal: -1,

datatype: "json",

and for now I dont have writed script code for merge two datas objects, but you can write yourself. I will post one ASAP.

So i hope that this is good idea.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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