Table loading old value

Table loading old value

victorc218victorc218 Posts: 4Questions: 2Answers: 0

I'm trying to implement the simple inline editing with ajax submission to the server. When I change the value and submit, the table redraws with the old value. If I don't submit, it works like the example and updates the cell with the new value. How do I make the cell use the new value?

Answers

  • gyrocodegyrocode Posts: 126Questions: 6Answers: 30
    1. Make sure you submit data from all pages, not just current page. Please see jQuery DataTables: How to submit all pages form data for a demonstration of a technique to submit all data from all pages.

    2. Make sure that browser doesn't cache server's response by disabling caching with ajax.cache option. For example:

      ajax: {
        url: '/path/to/your/script',
        cache: false
      }
      

    See more articles about jQuery DataTables on gyrocode.com.

  • victorc218victorc218 Posts: 4Questions: 2Answers: 0

    Thanks for the response. I tried disabling caching but it didn't help.

    This is what my ajax config looks like.

            ajax: {
                url: 'endpoint',
                type: 'POST',
                headers: {
                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
                },
                cache: false,
            },
    
    

    If I remove it then the editor works as expected and the cell value gets updated.

  • allanallan Posts: 61,627Questions: 1Answers: 10,091 Site admin

    What is the JSON that the server is returning?

    Allan

  • victorc218victorc218 Posts: 4Questions: 2Answers: 0
    edited July 2017

    It looks something like this

    {
      "REb29a8b43b1e38257eb80da9dbda87a25": 
        {
          "transcription":"test"
        }
    }
    

    REb29a8b43b1e38257eb80da9dbda87a25 is used as the row identifier, DT_RowId

  • allanallan Posts: 61,627Questions: 1Answers: 10,091 Site admin

    Thanks for the extra information. That is not the format Editor is expecting which would explain the issue. Are you able to modify the returned JSON to match what Editor needs?

    If I remove it then the editor works as expected and the cell value gets updated.

    If you remove Editor, what are you using to edit the data and submit it?

    Allan

This discussion has been closed.