Editor submit on blur

Editor submit on blur

bkatesbkates Posts: 35Questions: 5Answers: 0
edited May 2016 in Editor

I have a datatable initialized with legacy ajax = true. I'm sending json data with the request:

editor = new $.fn.dataTable.Editor( {
                ajax: {
                    "url": url,
                    "contentType": "application/json",
                    "type": "POST",
                    "data": function ( d ) {
                        return JSON.stringify( d );
                    }
                },
                legacyAjax: true,
                table: "#table",
                idSrc: "id",
                fields: [ { name: "weekNumber" }, 


            // Activate an inline edit on click of a table cell
        $('#table').on( 'click', 'tbody td', function (e) {
            editor.inline( this, {
                submitOnBlur: true
            });
        });

The actual data sent to the server is:

{
    "action":"edit",
    "data":{"weekNumber":"1"},
    "id":"857578"
}

The server is returning:

{
    "data":[
        {
         "DT_RowId":"row_857578",
         "weekNumber":"2"
         }
      ]
}

The problem is the data table UI is not updating back to it's original state. i.e. normally week number is displayed as text but when I click on it it's transformed into an input box. And when I jump off the row, the value from the table is removed.

Any suggestions? Am I missing something?

Replies

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin

    What is happening here is that the server is only returning the value that was changed, but Editor requires that the data for the full row be returned. That is so information from the server, e.g. An updated time stamp, can be shown correctly.

    This is a requirement that will be relaxed in 1.6, but it is present at the moment I'm afraid.

    Regards,
    Allan

  • bkatesbkates Posts: 35Questions: 5Answers: 0

    ok, good to know. Thanks.

  • bkatesbkates Posts: 35Questions: 5Answers: 0

    I'm still having trouble. Here are my fields:

     fields: [ { name: "weekNumber" }, 
              { name: "weekSalesAmount"},
              { name: "salesWeek", type: "date", dateFormat: "yy-mm-dd",  dateImage:"/calender.png" },
              { name: "gameOnSale", type:  "radio", options: {
                                  "Yes": "Yes",
                                  "No": "No"
               }},
               { name: "fiscalYear" },
               { name: "fiscalYearWeek" },
               { name: "calendarYear" },
               { name: "calendarYearWeek" },
               { name: "quarter" },
               { name: "month" }
         ]
    

    My client to server request:

    {"action":"edit","data":{"weekNumber":"0"},"id":"857578"}
    
    And my response:
    
    {
        "data":[
         { "id":857578,"
               versionNum":6,
               "weekNumber":0,
               "salesWeek":"2015-10-10",
               "gameOnSale":"Yes",
               "fiscalYear":2016,
               "fiscalYearWeek":15,
               "calendarYear":2015,
               "calendarYearWeek":41,
                "quarter":4,
                "month":"October",
                "DT_RowId":"row_857578",
                "weekSalesAmount":"$853,500"}
        ],
        "draw":null,"recordsTotal":null,"recordsFiltered":null
    }
    
  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin

    That looks okay to me. Can you link to the page showing the issue so I can debug it please.

    Allan

  • bkatesbkates Posts: 35Questions: 5Answers: 0

    Can I send you a link via email?

  • bkatesbkates Posts: 35Questions: 5Answers: 0

    I just saw the "message" button. I'll send you a message.

This discussion has been closed.