Forum


17:27

16/01/2010

Hi
I was trying to make a simple editable grid like this
http://code.google.com/p/strut.....i/EditGrid
but when I make a click on the delete button, it dosen't send any value to the action
I did it:
JSP:
<sj:head useJqGridPlugin="true" jqueryui="true" jquerytheme="redmond"/>
<br/>
<s:url id="remoteurl" action="jsontable"/>
<s:url id="editurl" action="edit-grid-entry"/>
<sj:grid
id="gridedittable"
caption="Customer Examples (zazaza)"
dataType="json"
href="%{remoteurl}"
pager="true"
navigator="true"
navigatorSearchOptions="{sopt:['eq','ne','lt','gt']}"
navigatorAddOptions="{height:280,reloadAfterSubmit:true}"
navigatorEditOptions="{height:280,reloadAfterSubmit:false}"
navigatorEdit="false"
navigatorView="false"
navigatorDelete="true"
navigatorDeleteOptions="{height:280,reloadAfterSubmit:true}"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
editurl="%{editurl}"
editinline="true"
onSelectRowTopics="rowselect"
>
<sj:gridColumn id="id_auditorio" name="id_auditorio" index="id_auditorio" title="id_auditorio" formatter="integer" sortable="false"/>
<sj:gridColumn id="nombre" name="nombre" index="nombre" title="nombre" editable="true" edittype="text" sortable="true" search="true"/>
<sj:gridColumn id="descripcion" name="descripcion" index="descripcion" title="descripcion" sortable="false" editable="true" search="false"/>
</sj:grid>
Struts.xml
<struts>
<package name="jeck" extends="struts-default,json-default" namespace="/">
<action name="jsontable" class="com.action.JsonTable">
<result name = "success" type = "json"/>
</action>
<action name="edit-grid-entry" class="com.action.EditGridEntry">
<result>newjsp.jsp</result>
<result name="input">newjsp.jsp</result>
</action>
</package>
</struts>
And the class to edit the grid
public class EditGridEntry extends ActionSupport {
private String oper;
int id_auditorio;
String nombre;
String descripcion;
@Actions( {
@Action(value = "/edit-grid-entry", results = {
@Result(location = "newjsp.jsp", name = "success"), @Result(location = "newjsp.jsp", name = "input")
})
})
@Override
public String execute() throws Exception{
System.out.println("oper: "+oper);
Auditorio auditorio;
if (oper.equals("add"))
{
// log.debug("Add Auditorio");
auditorio = new Auditorio();
auditorio.setNombre(getNombre());
auditorio.setDescripcion(getDescripcion());
auditorio.setId_auditorio(id_auditorio);
System.out.println("AuditorioDAO.save(auditorio);");
}
else if (oper.equals("edit"))
{
//log.debug("Edit Auditorio");
System.out.println("AuditorioDAO.update(auditorio);");
//auditorio = AuditorioDAO.findById(null,getId_auditorio());
//auditorio.setNombre(getNombre());
//auditorio.setDescripcion(getDescripcion());
}
else if (oper.equals("del"))
{
System.out.println(getId_auditorio());
System.out.println(getNombre());
System.out.println(getDescripcion());
System.out.println("AuditorioDAO.delete(auditorio);");
//auditorio = AuditorioDAO.findById(null,getId_auditorio());
}
return SUCCESS;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public int getId_auditorio() {
return id_auditorio;
}
public void setId_auditorio(int id_auditorio) {
this.id_auditorio = id_auditorio;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getOper() {
return oper;
}
public void setOper(String oper) {
this.oper = oper;
}
}
I hope that someone can help me, thanks a lot
A good way to find out what jqGrid sends to the Server is to use Firbug or similar tools.
Choose Network -> XHR and try to delete your Grid Entry.
In the Post Tab of your Request you can see the paramters.
I sugegst that the ID always has the Name id and not id_auditorio.
Hope it helps
Johanens Geppert
My Blog: http://www.jgeppert.com @Twitter: http://twitter.com/jogep
Most Users Ever Online: 715
Currently Online:
59 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66