سؤال

Can anyone help me deleting a row from Struts 2 Jquery grid using an external button. I have included a button in the jsp as below

<sj:a id="delete" name="delete" onClickTopics="rowselect"
    button="true">Delete</sj:a>

and in the script tag I have written

$.subscribe('delete', function(event,data) {
    $("#gridedittable").jqGrid(‘delRowData’,row_id);
}

I am not able to get the rowid for the selected row to be deleted. Can any one help me with this as I am new to struts 2 jquery.

هل كانت مفيدة؟

المحلول

Hi you can get selected row by using the jqGrid api

$.subscribe('delete', function(event,data) {
    var rowid = $("#gridedittable").jqGrid(‘getGridParam’,'selrow');
    $("#gridedittable").jqGrid(‘delRowData’,row_id);
}

This assumed you set the multiselect param to false.

For multiselect , you have to use the option selarrrow instead.

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options

And the grid setting should be like

 <s:url var="remoteurl" action="jsontable"/>
    <sjg:grid
        id="gridtable"
        caption="Customer Examples"
        dataType="json"
        href="%{remoteurl}"
        pager="true"
        gridModel="gridModel"
        rowList="10,15,20"
        rowNum="15"
        rownumbers="true"
    >
        <sjg:gridColumn name="id" index="id" title="ID" key="true" sortable="false"/>
        <sjg:gridColumn name="name" index="name" title="Name" sortable="true"/>
        <sjg:gridColumn name="country" index="country" title="Country" sortable="false"/>
        <sjg:gridColumn name="city" index="city" title="City" sortable="false"/>
        <sjg:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" formatter="currency" sortable="false"/>
    </sjg:grid>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top