Question

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>
Was it helpful?

Solution

There is nothing wrong with your jsp code.

  1. You have to put your <sg:grid> and <sj:submit> tag inside the <s:form> tag and
  2. give an id to your form tag

Like below:

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

It will definitely work.

OTHER TIPS

Try this code

var s = $('#grid_id').jqGrid('getGridParam','selarrrow');
alert('selected rows:'+s);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top