0

i am using struts2. Get's all rows selected by the checkbox and send them to action?

My JSP:

<s:url var="remoteurl" action="jsontable"/>
<sjg:grid
    id="gridtable"
    caption="Example"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="gridModel"
    rowList="10,15,30"
    rowNum="10"
    rownumbers="true"
    multiselect="true"        
>

    <sjg:gridColumn name="id" index="id" title="ID" sortable="false" />
    <sjg:gridColumn name="nombre" index="nombre" title="Name" sortable="true" />

</sjg:grid>

//JAVASCRIPT

function ver(){
var s = jQuery("#gridtable").jqGrid('getGridParam','selarrrow');    
var i, selectedData = [];
alert(s);
if (s.length>0) {
    for (i = 0; i < s.length; i++) {            
        selectedData.push(jQuery("#gridtable").jqGrid("getRowData", s[i]));                     
    }       
}   

}

How to send selectedData to action?

Diosney
  • 10,520
  • 15
  • 66
  • 111
YanOner
  • 13
  • 8
  • A grid column should implement a checkbox model. – Roman C Aug 27 '13 at 15:01
  • multiselect="true" is active. – YanOner Aug 27 '13 at 15:45
  • you need like multickecked="true" – Roman C Aug 27 '13 at 15:50
  • how make to httprequest for strust2? – YanOner Aug 27 '13 at 16:10
  • Wow, you are needed [this](http://stackoverflow.com/questions/16749885/action-to-accept-dynamic-json-data-from-user-interface/16752302#16752302) – Roman C Aug 27 '13 at 17:30
  • function ver(){ var s = jQuery("#gridtable").jqGrid('getGridParam','selarrrow'); var i, selectedData = []; alert(s); if (s.length>0) { for (i = 0; i < s.length; i++) { selectedData.push(jQuery("#gridtable").jqGrid("getRowData", s[i])); } } $.ajax({ type: "POST", url: "test", data : selectedData, dataType:"JSON", contentType: "application/json; charset=utf-8" }); } Not working for me y.y. What need? .jar? – YanOner Aug 27 '13 at 19:09
  • Not working is a usual thing, because you didn't try it. Programming is not easy thing. You need some more time to get realized. And jars, ofcourse you need if you haven't yet, read the answer carefully. – Roman C Aug 27 '13 at 19:21
  • But I thought you will do it without ajax, aren't you? – Roman C Aug 27 '13 at 19:27
  • I am trying in every way possible with or without ajax ... e.e Not working for me $.ajax and XMLHttpRequest u.u – YanOner Aug 27 '13 at 19:57
  • This is the same, Ajax. I thought you need HttpRequest. – Roman C Aug 27 '13 at 20:05
  • function http() { var client = new XMLHttpRequest(); client.open("POST", "test.action"); client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); client.send(null); } not work >.<... – YanOner Aug 27 '13 at 20:48

0 Answers0