Datables is not updated after onblur event occurs

Datables is not updated after onblur event occurs

henry2021henry2021 Posts: 13Questions: 1Answers: 0

https://debug.datatables.net/alenic
Description of problem:
After having updated a cell onblur event occurs and the server side method is called and completed; I have verified that json response is correct but the datatable is reset with all 0 values.

Until few days ago the datatable was updated regularly with data returned from server side. This strange behaviour has been reported some days ago (the edited cell is reset to 0 value )

I 've also updated DataTables from 1.10.21 to 1.13.4 and Editor from 2.0.5 to 2.1.2, but this has not resolved my issue.

This is how onBlur event is called in my code:

editor.inline(table.cell(this).index(), {
onBlur: 'submit'
});

Thanks for your help

Replies

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    This example, using the same code as you, is working.

    I have verified that json response is correct

    Are you using the browser's network inspector to see the XHR response?

    but the datatable is reset with all 0 values.

    Sounds like something specific with your page since the linked example works. Can you provide a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    Hi, thanks for your reply.
    You can verify the real behavior browsing this link:
    https://ordini.optoteam.it/

    At the top of the initial page you have an horizontal menu; select "PREMONTATI"
    then a login is required.
    Use the following credentials to authenticate
    Email: test@optoteam.it
    Password: Optoteam2023%

    After successful login you should land to a page for PREMONTATI; just select the checkbox "I Need you" on the left side filter and some pictures of eyeglasses should appear.
    Click on a picture and then you should see a datatable grid.
    This grid shows green cells that can be edited with numeric values; try to enter a numeric value in a green cell, then clicking out the edited cell should let the cell be updated with the new value just entered, but the cell results to be reset to 0 value.

    What we expect is that the edited cell is updated with the new value.

    If you need more informations please let me know.
    I hope you have all is needed to debug.

    Thanks for your help.

    Enrico.

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

    Thanks for the link! When I click to blur after changing a value I can see the POST request made to https://ordini.optoteam.it/api/apipremontati. That includes the edited value - e.g.:

    data[NERO+G10500][Qta100]: "3"
    

    The response from the server contains:

    qta100: 3
    

    So Immediately there is a discrepancy between the field name submitted and the data returned - i.e.

    'Qta100' !== 'qta100'
    

    What code are you using at the server-side for this?

    I think your label and name values might be the wrong way around in the Editor configuration. i.e. change:

    { label: "qta100", name: "Qta100" },
    

    to be:

    { name: "qta100", label: "Qta100" },
    

    Allan

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    Hi Allan thanks again for your help.
    I will try to change
    { label: "qta100", name: "Qta100" },
    in
    { name: "qta100", label: "Qta100" },

    What I cannot understand is that this code has not been modified for several months and was running correctly.

    Anyway, serverside I have Asp.Net Core and the response is converted in json format.

    I will let you know if this resolves the issue.

    Enrico.

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    Changing the editor configuration in this way has not resolved the issue: the cell is still reset to 0.

    fields: [
    { label: "idModello", name: "IdModello" },
    { label: "fotoColoreProdotto", name: "FotoColoreProdottoUrl" },
    { label: "codModello", name: "CodModello" },
    { label: "desColore", name: "DesColore" },
    { label: "qta000", name: "Qta000" },
    ** { label: "Qta100", name: "qta100" },** <=====================
    { label: "qta150", name: "Qta150" },
    { label: "qta200", name: "Qta200" },
    { label: "qta250", name: "Qta250" },
    { label: "qta300", name: "Qta300" },
    { label: "qta350", name: "Qta350" },
    ....
    "columns": [
    { "data": "idModello", "name": "IdModello", "autoWidth": true },
    {
    "data": "fotoColoreProdottoUrl",
    "name": "FotoColoreProdottoUrl",
    "render": function (data, type, row) {
    return '<img src="' + data + '" />';
    }
    },

            { "data": "codModello", "name": "CodModello", "autoWidth": true },
            { "data": "desColore", "name": "DesColore", "autoWidth": true },
    
            { "data": "qta000", "name": "Qta000", "autoWidth": true, editField: "Qta000" },
         **   { "data": "qta100", "name": "qta100", "autoWidth": true, editField: "qta100" },**
            { "data": "qta150", "name": "Qta150", "autoWidth": true, editField: "Qta150"},
            { "data": "qta200", "name": "Qta200", "autoWidth": true, editField: "Qta200" },
            { "data": "qta250", "name": "Qta250", "autoWidth": true, editField: "Qta250" },
            { "data": "qta300", "name": "Qta300", "autoWidth": true, editField: "Qta300" },
            { "data": "qta350", "name": "Qta350", "autoWidth": true, editField: "Qta350" },
            { "data": "prezzoConfidenziale", "name": "PrezzoConfidenziale", "autoWidth": true }
    
  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin
    edited May 2023

    Okay, if it was working before, then I was probably guessing wrong. Are you using our .NET libraries at the server-side?

    Allan

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    No, I'm not using DataTable .NET libraries server-side. All Datatable code is used from javascript at the moment.

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    Hi, the user test@optoteam.it has been renabled.
    Do you need more time to investigate and fix the issue ?
    Any other suggestions I can check to fix the issue related to onBlur event ?

    Enrico.

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

    Apologies for the delay in getting back to you. I just tried to take another look, but I'm getting a HTTP Error 500.30 - ANCM In-Process Start Failure error at the moment. I'll check back again later.

    Allan

  • henry2021henry2021 Posts: 13Questions: 1Answers: 0

    Thank you, Allan, I've found a workaround serverside to resolve and now the editor datatable is updated correctly.

    Enrico.

Sign In or Register to comment.