简体   繁体   English

如何访问struts jquery网格插件的选定行的数据?

[英]How to access data on a selected row of struts jquery grid plugin?

Here's a brief code of the Grid: 这是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. 访问的id是项目数据库中行的event.originalEvent.id id。

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 or 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 :) 这解决了问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM