0

I have a page designed with JQGrid in a div and the form (with fields) in another div. When I select a row in JQGrid I want to populate data for fields in the form based on row id.

<div id="data_div" class="results">
<table id="grid_table">
    <tr><td></td></tr>
</table>
<div id="pager" />
</div>
<div id="people-info">
<table><tr><td> <s:textfield key="act.actpeople[0].firstName" /></td></tr></table>
</div>

This works with hardcoding 0,1,2 indexing. I want to write something like:

<div id="people-info">
<table><tr><td> <s:textfield key="act.actpeople[${i}].firstName" /></td></tr></table>
</div>

Using Struts 2 and JSON for JQGrid; In my javascript am obtaining selected row Id but how can I get that Id for indexing? What are my options?

user1769790
  • 1,183
  • 3
  • 11
  • 23

1 Answers1

1

As I understand your asking how to dynamically populate data inanother form based on what row is selected in your jqGrid. Inside your jqGrid setup you can use the

onSelectRow: function (rowid) {
   var idRowData = $(this).jqGrid('getRowData', rowid);

   //set your form fields to the selected row column values
   FormField1.val(idRowData.Column1Name);
   FormField2.val(idRowData.Column2Name);
   //etc.....
}
Mark
  • 3,123
  • 4
  • 20
  • 31