Forum



20:20

15/06/2010

Hi,
Trying to use true scrolling on an existing grid and not having any luck. The paging does work when I sort a column but not on initial data load. Also I am needing to retain the values selected everytime data is loaded. This is a multiselect grid and I am using the latest build of jqgrid
* jqGrid 3.7.1 - jQuery Grid
* Date:2010-06-15
* Modules: grid.base.js; jquery.fmatter.js; grid.custom.js; grid.postext.js; grid.jqueryui.js;
The grid code is this.
$("#list").jqGrid(
{
scroll: 1,
url:'../Todo/todoHandler.cfm?event=todo.getLocations', //CFC that will return the users
datatype: 'json', //We specify that the datatype we will be using will be JSON
colNames:['ID','Name','State','OPUnit'], //Column Names
colModel :[
{name:'id',index:'id',sorttype:"int",width: 20, hidden:true},
{name:'Name',index:'Name', width:250,align:"left",sorttype:"text"},
{name:'State',index:'State', width:250,align:"left",sorttype:"text"},
{name:'OPUnit',index:'OPUnit', width:180,align:"left",sorttype:"text"}
],
pager: '#pscrolling', //The div we have specified, tells jqGrid where to put the pager
rowNum:200, //Number of records we want to show per page
sortorder: "asc", //Default sort order
sortname: "Name", //Default sort column
postData: {usertype: 'User'},
viewrecords: true, //Shows the nice message on the pager
height:400, //I like auto, so there is no blank space between. Using a fixed height can mean either a scrollbar or a blank space before the pager
mtype:'GET',
gridview: true,
rownumbers: true,
multiselect: true, //gridMultiSelectSwitch,
//Things to do when grid is finished loading
loadComplete:function(){
var ids = $('#list').getDataIDs();
var gridRecCount = 0;
if ($('#list').getGridParam('records') > 0) {
gridRecCount = $('#list').getGridParam('records');
}
if (gridRecCount == 0) {
if ($('#initGridLoad').val() == 1) {
$('#ResultList').hide();
$('#resultNoRecord').show();
}
}
else {
$('#ResultList').show();
$('#resultNoRecord').hide();
}
setTimeout(function(){
<cfoutput>
if ( valueArray[0] != undefined ) {
for(var i=0; i<valueArray.length; i++){
$('##list').setSelection(valueArray[i],true);
};
};
</cfoutput>
parent.iframeInit();
}, 500);
},
gridComplete: function() {
},
onSelectAll : function(aSel,selected) {
var value = '' ;
value = jQuery("#list").getGridParam('selarrrow');
//alert(value);
$('#locationId').val(value);
},
onSelectRow : function(rowid, selected){
var value = '' ;
value = jQuery("#list").getGridParam('selarrrow');
$('#locationId').val(value);
jClist = value;
},
//The JSON reader. This defines what the JSON data returned from the CFC should look like
jsonReader: {
root: "ROWS", //our data
page: "PAGE", //current page
total: "TOTAL", //total pages
records:"RECORDS", //total records
userdata:"USERDATA", //Userdata we will pass back for feedback
cell: "", //Not Used
id: "0" //Will default to frist column
}
}
);
Thanks
Kevin
11:35

Moderators
30/10/2007

Hello,
There is internal function called selectionPreserver which do this automatically for you when you are in multiselect mode.
So remove you code from loadComplete and you will have what you want.
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.
06:39

15/06/2010

tony said:
Hello,
There is internal function called selectionPreserver which do this automatically for you when you are in multiselect mode.
So remove you code from loadComplete and you will have what you want.
Regards
Tony
tony,
Thanks for the response. I ended up having to slightly modify what you see there for preserving my choices. The reason for that code is that I am using the grid to select options in a form wizard, so I have to repopulate on browser paging.
If there is a way to use selectionPreserver to pass in a already defined set of values I'll do that (as this funciton is not documented I have not looked at the source).
My other issue is that the aboe code I posted I cannot get 'true scrolling' to work. So not sure if an option I specified is preventing that.
Thanks.
Most Users Ever Online: 715
Currently Online:
87 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66