I've got a basic jqgrid implementation.
$('.fsJqGrid').jqGrid({
datatype: "local",
height: 175,
colNames: ['FeatureId', 'Name', ''],
colModel: [
{ name: 'FeatureId', index: 'FeatureId', width: 75, align: 'left',
sorttype: "int", hidden: true, key: true },
{ name: 'Name', index: 'Name', width: 180 },
{ name: 'tools', index: 'tools', width: 150}
]
});
function FeatGridAddRow(jqTableName, feature) {
///<summary>Adds a row of data to a Feature JQGrid</summary>
var RowId = $("#" + jqTableName).jqGrid('getGridParam', 'reccount');
feature.tools = 'MyToolHtml';
$("#" + jqTableName).jqGrid('addRowData', RowId, feature); //jqgrid
} //function
function FeatGridUpdateRow(featureId, newName) {
///<summary>Updates JQGrid data row</summary>
//I need to find the rowId, based on the featureId parameter
var rowId = 0;
//update grid with new data
$("#tabFS0").jqGrid('setRowData' , rowId , {Name: newName});
} //function
I want to be able to update a row of data, but need to know the rowId to do so.
The only data i have is the key value (featureId).
So i'm looking for a way of finding the rowId based on the primary key value which i do know.
I've been looking at the jqgrid documentation, and i'm not seeing an obvious way of doing this.
UPDATE: The answer is to use my table PK as the rowId.
So, in the add function;
var RowId = $("#" + jqTableName).jqGrid('getGridParam', 'reccount');
$("#" + jqTableName).jqGrid('addRowData', RowId, feature);
becomes
$("#" + jqTableName).jqGrid('addRowData', feature.FeatureId, feature);