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
remapping columns issue
01/08/2014
19:21
Avatar
_Chris
New Member
Members
Forum Posts: 2
Member Since:
29/07/2014
sp_UserOfflineSmall Offline

Because the server software I'm using (coldfusion) uses a non-standard JSON format, I'm having to remap the columns.

Unfortunately, once I do this, when using the toolbar search boxes, the grid queries the server rather than doing so locally -- I set the loadonce:true parameter so that it would not query the server after the initial load.

Can anyone help me with this?

var gridCols = {set:false};

$(document).ready(function(){
var grid = $('#gridTest'); // JQuery object reference of table used for our grid display

/*
* FUNCTION populateGrid
* Used as the 'datatype' attribute of the jqGrid config object, this method
* is used to handle the ajax calls and data manipulation needed to populate
* data within our jqGrid instance.
* @postdata (object) - this is the object passed as the 'postData' attribute
* of our jqGrid instance.
*/
var populateGrid = function (postdata) {
$.ajax({
url: './cfc/Schools.cfc',
data:postdata,
method:'GET',
dataType:"json",
success: function(d,r,o){
if(d.SUCCESS){
// If loading for the first time, let's find out to which
// array positions our columns map.
if(!gridCols.set){
for(var i in d.DATA.COLUMNS){
gridCols[d.DATA.COLUMNS[i]] = parseInt(i);
}
gridCols.set = true;
}
grid.jqGrid('setGridParam',{remapColumns:[
gridCols['SCH_ID'],
gridCols['SCH_NAME'],
gridCols['SCH_LOCATION_NAME'],
gridCols['SCH_IMAGE_FILENAME'],
gridCols['SCH_ACTIVE'],
gridCols['CONFERENCENAME'],
gridCols['SUBCONFERENCENAME']
]});
grid[0].addJSONData(d);
} else {
alert(d.MESSAGE);
}
}
});
};

grid.jqGrid({
loadonce: true,
gridview: true,
autowidth: true,
caption: 'Schools',

loadui: 'block',
altRows: true,
deepempty: true,
viewrecords: true,
sortname: 'SCH_NAME',
sortorder: 'asc',
colNames:['ID','School Name','Location Name','Image Filename','Active','Conference Name','Sub-Conference Name'],
colModel: [
{name:'SCH_ID',index:'SCH_ID',key:true,hidden:true},
{name:'SCH_NAME',index:'SCH_NAME',sorttype:'text',resizable:true},
{name:'SCH_LOCATION_NAME',index:'SCH_LOCATION_NAME',sorttype:'text',resizable:true},
{name:'SCH_IMAGEFILENAME',index:'SCH_IMAGEFILENAME',sorttype:'text',resizable:true},
{name:'SCH_ACTIVE',index:'SCH_ACTIVE',width:60,align:'center',stype:'select',sorttype:'numeric',editable:true,edittype:'checkbox',search:true,formatter:'checkbox',resizable:false,
editoptions: {
value: "1:Yes;0:No"
},
searchoptions: {
sopt:['eq'],
value: ":All;1:Yes;0:No",
defaultValue: "1"
}},
{name:'CONFERENCENAME',index:'CONFERENCENAME',sorttype:'text',editable:false,resizable:true},
{name:'SUBCONFERENCENAME',index:'SUBCONFERENCENAME',sorttype:'text',editable:false,resizable:true}
],
prmNames:{page:"pageIndex",sort:"sortCol",order:"sortDir",rows:"pageSize"},
postData:{method:"GetSchools",returnFormat:"JSON"},
datatype: populateGrid,
jsonReader: {
id: "SCH_ID",
root: function(obj){return obj.DATA.DATA;},
page: "pageIndex",
total: function(obj){return parseInt(obj.pageCount);},
records: function(obj){return parseInt(obj.recordCount);},
cell:""
}
});

grid.jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:false});
grid.jqGrid('filterToolbar',{stringResult:true,searchOnEnter:false});
});

11/08/2014
14:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

 

You put the function populateGrid in datetype parameter

 

datatype: populateGrid

 

This is wrong. Note that if a date type is function it is called every time (instead that you set loadonce true)  you want to do something with the data - serach and etc...

One possible solutuion is after this is completed you can set a datetype again to local usin setGridparam

 

Regards

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