No data receibed when Queuing changes in Editor

No data receibed when Queuing changes in Editor

Roberto Sanz PerezRoberto Sanz Perez Posts: 3Questions: 1Answers: 0

Hi, I have followed the guide described in this blog https://datatables.net/blog/2017-10-24
I have this Editors:

 editorOpts =  {
               table: "#erdAnmCaConstTable",
               idSrc: "anomalouscadatumId",
               fields : [
            {
                           data  : "criticalAreaCode",
                           name  : "criticalAreaCode"
                    },{
                        data  : "a",
                        name  : "a"
                    }, {
                        data  : "b",
                        name  : "b"
                    }, {
                        data  : "c",
                        name  : "c"
                    }, {
                        data  : "x",
                        name  : "x"
                    }]   ,
                     formOptions: {
                         inline: {
                             onBlur : 'submit'
                         }
                     }
           } ;
           editor = new jq.fn.dataTable.Editor(editorOpts);

           editor.on('postEdit', function(e, json, data){
             changedRows.push('#'+data.anomalouscadatumId);            
           })

           ajaxEditor = new jq.fn.dataTable.Editor(
                    jq.extend(true, {
                        ajax : '/PSSC/ErdiModificationController_updateDataGrid.dopss?identifier=${ErdWithErdiForm.identifier}'
                    }, editorOpts)   
           );
           jq('#erdAnmCaConstTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
                     editor.inline( this );
           } );
        // This is the onClick of my update button
         function updateGrid(){
                    ajaxEditor
                           .edit(changedRows, false)
                           .submit();
                    changedRows.length = 0;
       }

The DataTable

 erdAnmCaConstTable = jq("#erdAnmCaConstTable").DataTable({
             destroy: true,
             ajax : {"url":'/whatever.dopss?identifier=${ErdWithErdiForm.identifier}',
                      "type": 'POST',
                      "method":"POST",
                     "dataType": "json",
                      "contentType": "application/json",
                      "dataSrc": ''
                      },
             rowId: "anomalouscadatumId",
             select : true,
           aoColumns : [ {
                    "data" : "anomalouscadatumId",
                    "targets" : [ 1 ],
                    "title" : "hiddenTitle",
                    "defaultContent" : "",
                    "visible": false, 
                    "sClass": "dt-center"
             }, ..................

When i recibed the ajax call on java, the parameter 'data' does not exits (null) and action is edit

       @RequestMapping(value = "/ErdiModificationController_updateDataGrid.dopss")
       public void updateDataGrid(HttpServletRequest request, HttpServletResponse response) {
             String action = request.getParameter("action");
             String data = request.getParameter("data");
             System.out.println(action);
             System.out.println(data);
      }

Console.....
edit
null

Why 'data' is null???????

Answers

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    In your browser:

    1. Show the "Inspector" for the document
    2. Show the Network tab
    3. Reload the page
    4. Then trigger the actions to cause an edit action that will be submitted to the server
    5. You should see the XHR in the network tab for that edit request.
    6. Show its "Headers" (or "Parameters" if you are using Firefox) - what data does it show that is being sent to the server?

    Thanks,
    Allan

  • Roberto Sanz PerezRoberto Sanz Perez Posts: 3Questions: 1Answers: 0

    hi,
    this are the paremeters.....

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Perfect - thank you. That shows that the client is sending a data parameter (which is an object that contains more information).

    I suspect what is happening is that .NET is not decoding the object for you automatically like most other frameworks will. So there are two options:

    1. The easiest will be to use ajax.data to send JSON to the server, and just de-serialize that, rather than attempting to decode the HTTP parameter names.
    2. Use the DtRequest object from our libraries which can be used to perform the HTTP decoding for you.

    Regards,
    Allan

This discussion has been closed.