Does anyone know how to get the cells value of the selected row of JQGrid ? i m using mvc with JQGrid, i want to access the value of the hidden column of the selected row ?
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
You can use in this manner also
yo have to declarate de vars...
var nombre_img_articulo = $('#list').jqGrid('getCell', selectedRowId, 'img_articulo');
Just to add, you can also retrieve a jqGrid cell value, based on the rowID plus column index (rather than the Column name):
So, to fetch the value in the forth column (column index # 3) for the row with primary key ID 1234, we could use this:
Btw, on a completely unrelated topic (but please don't vote me down):
I didn't realise that you can, fairly easily, link text boxes to your jqGrid, so your users can do instant searching, without having to open the Search dialog.
To do this, you need a bit of HTML like this:
And a bit of JavaScript like this:
This is a real game-changer for me... it really makes jqGrid much more user friendly.
Users can immediately start typing in their search string, rather than needing to open the Search dialog, remember to change the operator to "contains", then start typing, and close the search dialog again.
First you can get the
rowid
of the selected row with respect ofgetGridParam
method and 'selrow' as the parameter and then you can use getCell to get the cell value from the corresponding column:The
'columnName'
should be the same name which you use in the'name'
property of thecolModel
. If you need values from many column of the selected row you can use getRowData instead of getCell.Just Checkout This :
Solution 1 :
In Subgrid Function You have to write following :
Where
row_id
is the variable which you define in subgrid as parameter. Andid
is the column name which you want to get value of the cell.Solution 2 :
If You Get Jqgrid Row Id In alert Then set your primary key id as
key:true
In ColModels. So You will get value of your database id in alert. Like this :Use "selrow" to get the selected row Id
var myGrid = $('#myGridId');
var selectedRowId = myGrid.jqGrid("getGridParam", 'selrow');
and then use getRowData to get the selected row at index selectedRowId.
var selectedRowData = myGrid.getRowData(selectedRowId);
If the multiselect is set to true on jqGrid, then use "selarrrow" to get list of selected rows:
var selectedRowIds = myGrid.jqGrid("getGridParam", 'selarrrow');
Use loop to iterate the list of selected rows:
var selectedRowData;
for(selectedRowIndex = 0; selectedRowIndex < selectedRowIds .length;
selectedRowIds ++) {
}