Reputation: 21
I created a grid using jquery struts2 grid plugin. I have a grid column which is the primary key of the table that I set to non-editable. When I try to edit one of the rows of the table in the grid, the key column is not somewhat passed to the server. I tried setting the editable attribute of the key column to true then that's the only time it sent the key to the server. In the showcase, the id is also set to non-editable but the server receives it as parameter. Kindly help me out on this. I might be missing something.
Here is my code for the jsp:
<s:url id="adm201_grid" action="adm201grid">
<s:param name="bomId" value="%{bom.bomId}"/>
</s:url>
<s:url id="adm201_edit_grid" action="adm201editgrid">
<s:param name="bomId" value="%{bom.bomId}"/>
</s:url>
<s:url id="select_material" action="select_material"/>
<sjg:grid
gridModel="gridModel"
caption="Bill of Materials"
href="%{adm201_grid}"
dataType="json"
pager="true"
navigator="true"
navigatorSearchOptions="{multipleSearch:true}"
navigatorEdit="true"
navigatorDelete="true"
rowList="10,15,20"
rowNum="15"
editurl="%{adm201_edit_grid}"
editinline="false"
multiselect="true"
width="500"
navigatorAddOptions="{reloadAfterSubmit:true}"
navigatorEditOptions="{reloadAfterSubmit:false}"
>
<sjg:gridColumn
name="bomMatId"
index="bomMatId"
title="BOM Material ID"/>
<sjg:gridColumn
name="material.materialId"
title="Material"
sortable="true"
editable="true"
edittype="select"
editoptions="{dataUrl:'%{select_material}'}"
formatter="integer"
width="40"/>
<sjg:gridColumn
name="material.descrip"
title="Description"
sortable="true"
width="150"/>
<sjg:gridColumn
name="material.unit"
title="Unit"
sortable="true"
width="30"/>
<sjg:gridColumn
name="quantity"
title="Quantity"
sortable="true"
editable="true"
edittype="text"
formatter="integer"
width="40"/>
</sjg:grid>
Here is my code for the edit action:
public class ADM201EditGrid extends ActionSupport {
private static final long serialVersionUID = 3887575129335166744L;
private String oper;
private BOMMaterials bomMaterials;
private BOMMaterialsDao bomMatDao = new BOMMaterialsDao();
private Long bomId;
private Material material;
private Long quantity;
private Long bomMatId;
// getters and setters
@Override
@Actions( {
@Action(value = "/adm201editgrid", results = {
@Result(name = "success", location = "simpleecho.jsp"),
@Result(name = "input", location = "simpleecho.jsp")
})
})
public String execute() throws Exception {
if (oper.equals("add") || oper.equals("edit")) {
bomMaterials = new BOMMaterials();
bomMaterials.setBomId(bomId);
bomMaterials.setBomMatId(bomMatId);
bomMaterials.setMaterial(material);
bomMaterials.setQuantity(quantity);
bomMatDao.save(bomMaterials, bomMaterials.getBomMatId());
}
return SUCCESS;
}
}
Hoping for you immediate replies. Thanks a lot!
~ Honey =)
Upvotes: 0
Views: 2210
Reputation: 13734
Instead of setting editable to false, try setting hidden to true, in which case it'll be passed to the server and will not be visible in the add/edit dialog box of the grid.
Upvotes: 1