I have a jqGrid and there are several pages of items. I have the Id of a row which may be on page one or may be buried in the other pages somewhere.
Given the ID of the row, How do I programmatically select such a row ? I am using the click event of a button as follows
.on("click", function(){
var myId = $(this).attr("id");
$("#studentGrid").jqGrid.setSelection(myId, true);
});
When I click on the button I get the following th the firebug console.
TypeError: this.each is not a function
Any ideas ?
EDIT
So I opted to repopulate the grid with just one record. The thing is I am not using local data. My dataType is "json". Like this
$("#studentGrid").jqGrid({
url: '<c:url value="/students/studentjsondata"/>',
datatype: 'json',
height: 'auto',
colNames:['id','First Name', 'Last Name', 'Other Name' ,'Date Of Birth', 'Gender'],
colModel:[
//Bla Bla Bla
],
rowNum:10,
autowidth: true,
pager: '#pager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Students",
emptyrecords: "Empty Records",
subGrid: true,
/* <![CDATA[ */
onSelectRow: function(id){
if((lastsel != 0)&&(id!==lastsel)){
$("#studentGrid").jqGrid('collapseSubGridRow', lastsel);
}
lastsel=id;
}/* ]]> */ ,
subGridOptions: {
"plusicon" : "ui-icon-triangle-1-e",
"minusicon" : "ui-icon-triangle-1-s",
"openicon" : "ui-icon-arrowreturn-1-e",
"reloadOnExpand" : true,
"selectOnExpand" : true
},
subGridRowExpanded: function(subgrid_id, row_id) {
//Bla Bla Bla
}
});
I have the json string I want to repopulate the grid with. How do I re-initialize the grid with this new data. I the following json string with the corresponding logic as follows, but nothing happens.
{'page':'1', 'records':'1', 'total':'1', 'rows':[{'id':'7385', 'cell': ['Max', 'Payne', '', 'September 16, 2012', 'Male']}]}
.on("click", function(){
var myNewData = eval('(' + $(this).attr("griddata") + ')');
$("#studentGrid").jqGrid('setGridParam', { datatype: 'local', data: myNewData}).trigger('reloadGrid');
});