how to call a class or JQuery funcwhen clicked on new/Edit/Remove buttons of Datatables Editor

how to call a class or JQuery funcwhen clicked on new/Edit/Remove buttons of Datatables Editor

ghostriderghostrider Posts: 2Questions: 2Answers: 0
edited January 2016 in Free community support

I Have a J2EE+struts2 application in which I am using the DataTables Editor. I am new to DataTables API. Here is my code. I am unable to do few things 1) remove operation on my data 2) create Select dropdown box in the form that appears when you click on Edit/New buttons of DataTables Editor.

HTML:

        <table id="example" class="display" cellspacing="0" width="100%">
         <thead>
           <tr>
              <th>Description</th>
            <th>Category</th>
            <th>Payee</th>
            <th>Date</th>
            <th>Amount</th>
            <th>Income ID</th>
        </tr>
        </thead>
        </table>

Script:

    $(document).ready(function() {
      editor = new $.fn.dataTable.Editor( {
       "ajax": "refreshIncomeData",// struts2 fremework calls method( public String dataTableActions()) of a java Action class DataTableAction
       "table": "#example",
       "fields": [ {
            "label": "Description:",
            "name": "description"
        }, {
            "label": "Amount:",
            "name": "amount"
          }
        ]
     } );

      $('#example').DataTable( {
      dom: "Bfrtip",
      "ajax": "refreshIncomeData",
      serverSide: true,
      "aoColumns": [
                  {"mData":"description","bSearchable": true,"bSortable": true},
                  {"mData":"catergory.userCodeName","bSearchable": false,"bSortable": false},
                  {"mData":"payee.payeeName","bSearchable": false,"bSortable": false},
                  {"mData":"transactionDate","bSearchable": false,"bSortable": false},
                  {"mData":"amount","sWidth":"30px","bSearchable": false,"bSortable": true},
                  {"mData":"incomeID","visible":false}],
      select: true,
      buttons: [
        { extend: "create", editor: editor },
        { extend: "edit",   editor: editor },
        { extend: "remove", editor: editor }
       ]
     } );
     } );

All the parameters that the DataTable is sending to the server should be present in request object, But I can see only few parameters in the request which are listed below

   HttpServletRequest request=ServletActionContext.getRequest();

   /*columns[0][search][value]
columns[0][data]
columns[0][name]
columns[0][search][regex]
columns[0][orderable]
columns[0][searchable]
.............
    .............

columns[5][search][value]
columns[5][data]
columns[5][name]
columns[5][searchable]
columns[5][search][regex]
columns[5][orderable]
search[value]
draw
length
order[0][column]
order[0][dir]
start
search[regex]*/

Can some one tell me which parameters contains the information about the button(New/Edit/remove) which I have clicked? so that I can remove the data from DB using the primary key(incomeID) of the row

Answers

This discussion has been closed.