2

I am using jQuery and jQuery Grid 3.5.1 plugin in my Struts 2.1.8

I want to retrieve the multiselected rows on <sj:submit> button. I used onClickTopics for submit button.The jQuery code for retrieving grid rows is as:

$.subscribe('getrows',function(event,data){
var s;
s=$('#grid_id').jqGrid('getGridParam','selarrow');
alert('selected rows:'+s);
});

the alert dialog always displays null. The grid is working fine.

The submit button is as:

<sj:submit value="Rows" onClickTopics="getrows" button="true"/>

when I checked in firebug, on clicking the submit button it pops 1 error

TypeError: c is undefined in file : struts2/jquery.struts2.min.js?s2j=3.5.1

What is this error and why it is not working?

<sjg:grid 
    gridModel="csvDetailList" 
    id="grid_id" 
     caption="Csv Files Pending"
    dataType="json" href="%{remoteurl}"
    multiselect="true" multiboxonly="true"
    >
    
    
    <sjg:gridColumn name="csv_filename" title="File" width="400"></sjg:gridColumn>
    <sjg:gridColumn name="month" title="Month" width="100"></sjg:gridColumn>
    <sjg:gridColumn name="year" title="Year" width="100"></sjg:gridColumn>
    <sjg:gridColumn name="upload_status" title="Upload Status" width="150" ></sjg:gridColumn>
    
    
</sjg:grid>
4

2 回答 2

1

试试这个代码

var s = $('#grid_id').jqGrid('getGridParam','selarrrow');
alert('selected rows:'+s);
于 2014-03-31T11:33:13.657 回答
1

你的jsp代码没有问题。

  1. 你必须把你的<sg:grid><sj:submit>标签放在标签<s:form>里面
  2. 给你的表单标签一个 id

如下所示:

<s:form id="try">
<sg:grid>
</sg:grid>
<sj:submit id="grid_multi_getselectedbutton" value="Get Selected Rows" onClickTopics="getselectedids" button="true"/>
</s:form>

它肯定会奏效。

于 2014-03-31T12:57:02.303 回答