Table not updating after edit

Table not updating after edit

nttdev1nttdev1 Posts: 2Questions: 1Answers: 0

Hello, I am working with Datatables and Editor. I have the edit working from the edit button (i plan to get inline working next) but after the edit the grid isn't reflecting the change. If I refresh the page the change is there. The service returns 200 and I return the same JSON object that was sent. Should I be doing something else? Do I need to call something to manually refresh the grid?

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited October 24

    The Editor client server docs explain how the data should be returned. Also you can see the expected behavior in this example.

    If this doesn't help then please provide a sample of the request and response using the browser's network inspector tool. Better is a link to a test case showing the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • nttdev1nttdev1 Posts: 2Questions: 1Answers: 0
    edited October 24

    Thanks for the response. The row is removed from the table after the edit completes.

    The request is:

    {
      "data": {
        "2": {
          "status": "Active",
          "stage": "Insight",
          "accountType": "Account",
          "accountName": "Test Account2",
          "bu": "Launcher",
          "industry": "Industry",
          "sfdcNumber": "43",
          "opportunityName": "OppName",
          "pursuitType": "PursuitType",
          "expectedClose": "2024-10-31T00:00:00",
          "expectedValue": "10000",
          "wave": "Wave1",
          "alignedWithBULead": "true",
          "mcKinsey": "true",
          "notes": "Notes",
          "typeOfEngagement": "EngagementType",
          "transformationExec": "Exec",
          "ea": "EA",
          "bv": "BV",
          "pursuitLeader": "Leader",
          "pa": "PA",
          "alliancePartner": "Partner",
          "thirdPartyInPlay": "Cubs",
          "ceName": "CEName",
          "id": "2"
        }
      },
      "action": "edit"
    }
    

    The response is:

    {
        "data": {
            "id": "2",
            "accountType": "Account",
            "accountName": "Test Account2",
            "bu": "Launcher",
            "industry": "Industry",
            "sfdcNumber": "43",
            "opportunityName": "OppName",
            "opportunityID": null,
            "pursuitType": "PursuitType",
            "status": "Active",
            "stage": "Insight",
            "expectedClose": "2024-10-31T00:00:00",
            "expectedValue": "10000",
            "wave": "Wave1",
            "alignedWithBULead": true,
            "mcKinsey": true,
            "notes": "Notes",
            "typeOfEngagement": "EngagementType",
            "transformationExec": "Exec",
            "ea": "EA",
            "bv": "BV",
            "pursuitLeader": "Leader",
            "pa": "PA",
            "alliancePartner": "Partner",
            "thirdPartyInPlay": "Cubs",
            "ceName": "CEName",
            "createdBy": null,
            "createdDate": "0001-01-01T00:00:00",
            "modifiedBy": null,
            "modifiedDate": "0001-01-01T00:00:00"
        }
    }
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited October 24

    Are you using a Datatables provided server script?

    The response looks like this:

    {
        "data": {
            "id": "2",
    ...
        }
    }
    

    The Edit response is expected to be in the data object, like you have, but the row(s) are expected to be in an array even if its one row. It should look more like this:

    {
        "data": [
            {
                    "id": "2",
    ...
            }
        ]
    }
    

    Kevin

Sign In or Register to comment.