Parsing JSON params. in submitSuccess function

Parsing JSON params. in submitSuccess function

jasoncaditrackjasoncaditrack Posts: 14Questions: 6Answers: 0

I have a (possibly stupid) question about how to use the objects that are passed as parameters to submitSuccess in Editor, specifically, and other Datatables/Editor parameters generally.

The documentation shows the submitSuccess function as

function( e, json, data, action )

In order to get the value of a property, say 'vlots.lot_status' , from the 'data' parameter, I use simple object notation:

data.vlots.lot_status

But the 'json' object appears more convoluted, and to get the same property value from the 'json' object. I see from the structure of the object that I have to use

json.data[0].vlots.lot_status

I have 2 questions,
1. Is there a more direct way to address the properties in object 'json'
2. If not, is the structure of these parameter objects documented somewhere, or recommendations on how to parse them? It is not clear to me how to use some of the parameters in other functions/callbacks, and I wonder if I am missing something.

Many thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Yes, the JSON response from the server is a little more complex because of Editor's multi-row editing capabilities. You would need to loop over the json.data array if you are wanting to access the row data there.

    Can I ask what you want to do with it there? I'm just wondering if there might be a different option.

    Allan

  • jasoncaditrackjasoncaditrack Posts: 14Questions: 6Answers: 0

    Thanks Alan. I have not been using muti-row editing, but now I see how this requires the json.data[] array.

    To answer your question, I ended up using the 'data' parameter quite satisfactory, but I realized that I didn't really understand how these data structures are parsed.
    I checking the server data after an Update, against the original datatable data, so that I can highlight the background of any cell that the user changes. My Editor form contains a couple of input fields, but it is useful for the user to see which dataTable field was actually changed by the Update.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Sounds like a good use of it! Thanks for the update.

    Allan

Sign In or Register to comment.