How to access data in selected row struts jquery grid plugin?

Here is a brief grid code:

 <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 subscription function:

$.subscribe('rowselect', function(event, data) {
alert('Selected Row : ' + event.originalEvent.id);
});

Access to id is the identifier event.originalEvent.id of the row from the element database.

How can I access the price parameters and the name of the selected row? Can someone give an example of using syntax? is it through data or event?

Thank!

+3
source share
1 answer
$.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 :)

+6
source

Source: https://habr.com/ru/post/1796475/


All Articles