问题
(JSP - GRID) I have a grid that load data, i use a formatter="formatLink" in a column for add aspect hyperlink with the respective value of the cell,
<s:url id="remoteurl" action="lisaluXCodYNom" namespace="/"/>
<sjg:grid
id="gridtable"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="clientes"
reloadTopics="reloadMyGrid"
rowList="10,15,20"
rowNum="5"
rownumbers="true"
formIds="mcp"
onSelectRowTopics="rowselect"
>
<sjg:gridColumn name="codcli" index="codcli" title="Codigo" sortable="false" formatter="formatLink"/>
<sjg:gridColumn name="nomcom" index="nomcom" title="Alumno" sortable="false" width="300"/>
<sjg:gridColumn name="facultad.desfacres" index="desfacres" title="Facultad" sortable="false"/>
<sjg:gridColumn name="escuela.desesc" index="desesc" title="Escuela" sortable="false"/>
</sjg:grid>
(JAVASCRIPT) FormatLink, changes the content by hyperlink, openDialog, executes the action, sending the value of the selected cell in the grid. I capture that value in the object "cliente.getCodcli (cliente.codcli)"
<s:url var="ajax1" action="seleccionarfila" />
function formatLink(cellvalue, options, rowObject) {
return "<a href='#' onClick='javascript:openDialog("+cellvalue+")'>" + cellvalue + "</a>";
}
function openDialog(employee) {
//When I click on any link brings me here
$("#divresult").load("<s:property value="ajax1"/>?cliente.codcli="+employee);
}
(SAME JSP - DIV FOR UPDATE) I would like this div is upgraded with the information brings back the action on object "cliente.codcli"
<sj:div id="divresult"
dataType = "json" >
</sj:div>
MY STRUTS As you see i return all object "Cliente", because I need all the attributes in momery to be updated each div with respective atribute.
<action name="seleccionarfila" class="intranet.ConsultarAlumno" method="CargarDatos">
<result type="json">
<param name="root">
cliente
</param>
</result>
</action>
MY METODH "CargarDatos" This method does what in reality is: Fill a Object with the name "Cliente" that brings its attributes, "name", "surname", "phone", etc etc.. Based on the value of the selected cell (which is really is a code of any client)
public String CargarDatos() {
cliente = new Cliente();
cliente.setCodcli("2008502240");
cliente.setNomcom("ORTIZ");
cliente.set(New Object());
cliente.getObject.setOtherData1("OtherData"));
cliente.getObject.setOtherData2("OtherData2"));
return SUCCESS;
}
So the question goes like this: Clicking on a row, captured the value of the cell with title "Codigo" then my "seleccionarfila.action " is executed. In the method "CargarDatos" fill an Object with name "Cliente" (filled by hand just for this example, and as can see I have 3 attributes in the Object "Cliente": "codcli", "nomcom" and other object .... "Object" with your attributes)
Well, the upshot of all this is that the div with name "divresult" is updated with all the object "Cliente" and show it with {} and everything else, and only one div is updated.
So, my problem here is:
- I need to update many div in the same page.
- The divs should are based on a object "Cliente"
- The Object "Cliente" should fill based in the click of row the enter code here enter code here grid
Each attribute of this object 'cliente' respective update a div.
Example:
Div1 = Cliente.codcli
Div2 = Cliente.nomcom
Div3 = Cliente.Object.OtherData1
Div4 = Cliente.Object.OtherData2
etc...
That's what I can do?
chances are that the grid componet let me make an easier way. maybe I'm complicating unnecessarily.
来源:https://stackoverflow.com/questions/21144327/load-many-divs-from-a-grid-struts2-jquery-plugin