I have a struts2-Jquery grid. It is required that on double clicking a grid row
the grid row key should be caputerd and a struts2 action(returning json) to be called which fetches details from database corresponding to key and shows result in jquery dialog.
I implemented in following way but the dialog was not populating because the mapping is not correct .
I then used session to store and read at jsp but it shows same value every time
I need a help to find out how to know
$("#detailDialog").load("<s:url value="my-dialogAction"/>"+"?gridKey="+key);
should returns success and only then to publish
$.publish('loadSuccessConfirm');
Code snippets
———Jquery grid code ———
< sjg:grid id="mytable" ..
.. ..
onDblClickRowTopics="popup"
>
< sjg:gridColumn .. />
< sjg:gridColumn .. /> ..
————-java script—
< script type="text/javascript" >
$.subscribe('popup', function(event, data) {
var key = $("#mytable").jqGrid('getGridParam','selrow');
$("#detailDialog").load("<s:url value="my-dialogAction"/>"+"?gridKey="+key);
$.publish('loadSuccessConfirm');
});
< /script>
—————-dialog————
< sj:div id="detailDialog" name="detailDialog" >
< sj:dialog position="center" height="200" width="500" openTopics="loadSuccessConfirm" name="dialog1" id="dialog1" autoOpen="false" >
< s:iterator value="#session.comparePorts" status="stat" var="stack">
< tr>
< td><s:property value="#stack.airPortFrom"/> </td>
< td><s:property value="#stack.transportMode"/></td>
< td><s:property value="#stack.svc"/></td>
< td><s:property value="#stack.calcCostLoad"/></td>
< /tr>
< /s:iterator>
< /sj:dialog>
< /sj:div>
Update
I edited script code as below and it publishes after success but still dialog shows stale value and is not getting refreshed
$.subscribe('popup', function(event, data) {
var key = $("#mepctable").jqGrid('getGridParam','selrow');
$("#detailDialog").load("<s:url value="my-dialogAction"/>"+"?gridKey="+key,
function() { alert("success");$.publish('loadSuccessConfirm');});
});
The
<s:property />tag is evaluated at page render time and it would not be changed.May be you should put the dialog content as another jsp/action and use ajax to call that page using the
hrefattribute of<sj:dialog />. And to uselistenTopicsto make the dialog reload when there’s a double click on the row.https://code.google.com/p/struts2-jquery/wiki/DialogTag