1

I have a grid to show data in a tabular format as follows.

<s:url id="remoteurl" action="SizeGrid" namespace="/admin_side"/>
<s:url id="editurl" action="SizeCRUD" namespace="/admin_side"/>

<sjg:grid
    id="gridmultitable"
    caption="Size"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    navigator="true"
    navigatorSearchOptions="{sopt:['eq','ne','lt','gt']}"
    navigatorEdit="false"
    navigatorView="false"
    navigatorAddOptions="{height:280, width:500, reloadAfterSubmit:true}"
    navigatorEditOptions="{height:280, width:500, reloadAfterSubmit:false}"
    navigatorViewOptions="{height:280, width:500}"
    navigatorDelete="true"
    navigatorDeleteOptions="{height:280, width:500,reloadAfterSubmit:true}"
    gridModel="gridModel"
    rowList="5,10,15"
    rowNum="5"
    rownumbers="true"
    editurl="%{editurl}"
    editinline="true"
    multiselect="true"
    onClickGroupTopics="rowdelete"
    onSelectRowTopics="rowselect"
    onEditInlineSuccessTopics="oneditsuccess"
    viewrecords="true"
    shrinkToFit="false"
    width="1045"
    >

    <sjg:gridColumn name="sizeId" index="sizeId" title="%{getText('size.title.id')}" key="true" frozen="true" width="200" editable="false" dataType="Long" sortable="true" search="true" sorttype="integer" searchoptions="{sopt:['eq','ne','lt','gt']}"/>
    <sjg:gridColumn name="sizeCode" index="sizeCode" title="%{getText('size.title.code')}" editrules="{required: true}" width="780" editable="true" sortable="true" search="true" sorttype="text"/>

</sjg:grid>

<s:hidden name="idArray"/>

When the delete link is clicked, I would like to pass ids (sizeId in this case) of the selected rows as an array.

For this to be so, a JavaScript function needs to be called before an actual request to delete row(s) is triggered.

I have tried with the following raw/incomplete JavaScript function.

$.subscribe('rowdelete', function(event, data){
    var checks=$("#gridmultitable").find('input[type=checkbox]');
    var idArray =new Array();
    alert(checks.length);

    for(var i=0;i<checks.length;i++)
    {
        if(checks[i].checked)
        {
            var sizeId = checks[i].parentNode.parentNode;
            var id=sizeId.id;

            idArray.push($("#gridmultitable").jqGrid('getCell',id,'cellvalue'));
        }
    }
    document.getElementById("idArray").value=idArray; 
});

But this function is never invoked.

Is there a way to gather ids (sizeId in this case) of selected/checked rows so that they can be supplied as an array simply because ids are passed as a comma delimited string and I dislike gathering them using some functions like String#split() or StringTokenizer and parsing them to Long/Integer on the server.

The grid allows multiple rows to be selected as multiselect is set to true, multiselect="true".

Tiny
  • 27,221
  • 105
  • 339
  • 599

1 Answers1

0

For the selected/checked rows part ,here is the underlying grid project api. For multiselect=true , you can retrieve the selected rows's ids as an array by

$("#gridmultitable").jqGrid("getGridParam","selarrrow");
Quincy
  • 4,393
  • 3
  • 26
  • 40
  • Please let me know where can I put this line? The function itself as specified in the question is not invoked. (The system somehow didn't notify me about your answer). – Tiny Mar 07 '14 at 09:27