How to access data on a selected row of struts jquery grid plugin?
Here's a brief code of the Grid:
<s:url id="remoteurl" action="jsontable"/>
<sjg:grid
id="gridtable"
caption="Items Result"
formIds="gridSearchForm"
reloadTopics="reloadItemsGrid"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
navigator="true"
navigatorSearch="true"
navigatorRefresh="true"
viewrecords="true"
width="600"
pagerInput="false"
pagerPosition="center"
recordpos="right"
direction="rtl"
onSelectRowTopics="rowselect">
<sjg:gridColumn name="title" index="title" title="title" sortable="false"/>
<sjg:gridColumn name="price" index="price" title="price" formatter="integer"/>
and the subscribe function:
$.subscribe('rowselect', function(event, data) {
alert('Selected Row : ' + event.originalEvent.id);
});
The id accessed is the event.originalEvent.id id of the row from the database of the item.
How do I access the price and title parameters of the selected row? Can someone give an example for the syntax to be used? is it through data o开发者_高级运维r event?
Thanks!
$.subscribe('rowselect', function(event, data) {
var grid = event.originalEvent.grid;
var sel_id = grid.jqGrid('getGridParam', 'selrow');
var price = grid.jqGrid('getCell', sel_id, 'price');
alert(price); });
This solves the problem :)
精彩评论