Forum
19:03
28/04/2014
I've seen a few posts on this but none of these solutions seem to work. I am attempting to setup a jqGrid to work with a asp.net webmethod...this works fine, and it's very simple as I'm using a "loadonce" setup. So the data comes in and loads into the grid fine, but with this setup I can't perform any column sorting (does nothing) or toolbar filtering (always returns 0 rows). I have done all the usual things....setting the datatype to local, setting loadonce to true, etc....but nothing seems to work. I have the data being loaded separately via an ajax call, then manually setting the grid's 'data' attribute with the returned data, as this was recommended on another forum post for cases where the grid needs to be loaded dynamically (not on page load) and the query is parameterized.
I'll only post the client-side code since the issue is there, the server code is a standard JSON-serialized array (this data comes back correctly)...
The "onload" event for the page (initial setup of grid properties, but no data loaded)...
var mygrid = jQuery("#s3list").jqGrid({
//url:'',
datatype: 'local',
mtype: 'POST',
height: 206,
width: 400,
colNames:['Name', 'Mnemonic'],
colModel:[
{ name:'Name',index:'name', width:150, sorttype:'text' },
{ name:'Mnemonic',index:'mnemonic', width:250, sorttype:'text' },
],
rowNum:9999,
loadonce: true,
sortname: 'name',
hidegrid: false,
viewrecords: true,
rownumbers: false,
sortorder: "desc",
gridview : true,
caption:'Feature RVS: <select id="prrvs" onchange="GetFeatures();" style="width:300px;"></select>',
emptyrecords: "Select a RVS for features...",
ondblClickRow: function(id) {
alert('double-clicked: ' + id);
}
});
jQuery("#s3list").jqGrid('filterToolbar', { searchOnEnter: true, defaultSearch: 'cn' });
AERVSChange();
});
The event (drop down list change) that fires the AJAX request and sets the 'data' in the grid then triggers a reload (this works for populating the grid, but the sorting/searching is broken)...
function GetFeatures()
{
var rvsid = $('#prrvs').val();
$.ajax({
type: 'POST',
url: 'AEEditor.aspx/GetRVSProductRequirements',
data: "{'guidRVSGroupID' : '" + rvsid + "'}",
contentType: 'application/json; charset=utf-8;',
dataType: 'json',
success: function (msg)
{
var prdata = msg.d;
if (prdata.length > 0)
$('#s3list').jqGrid('setGridParam', { data:prdata }).trigger('reloadGrid');
else
{
// Clear grid data if empty set is returned...for some reason this doesn't clear grid...
$('#s3list').jqGrid('clearGridData', true);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Query error: ' + errorThrown);
}
});
}
Is there something I'm missing here? During some testing, I verified (after the grid is loaded) that the datatype is indeed set to 'local' and the loadonce is set to true. Is there something else I need to do? Thanks!
19:18
28/04/2014
Ok, as it turns out...for local/loadonce data....the "index" property of each sortable/searchable column (in the colModel) must be *exactly* (case sensitive) the same as the "name" property. Matching the case of these two properties in both of my columns fixed both the sorting and searching issues.
10:13
Moderators
30/10/2007
Hello,
Glad to hear you solved the problem.
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.
Most Users Ever Online: 715
Currently Online:
51 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