How to get all the data fields in datatable inline editor?
How to get all the data fields in datatable inline editor?
Abhishek K S
Posts: 12Questions: 1Answers: 1
I am using datatable inline editor, not able to get the data which are not editable using
editor.inline(this, {
submit: 'all'
});
Can anyone please help me with this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
When you say you're not able to get the data, where do you want to get it? On the server, or the client? Before editing, or before submitting? Please add more information so we can help you,
Colin
Now I added few fields in the editor and made it as hidden now I am able to get in data of preSubmit event but unable to get it in the server side(not using datatable dll's, normal web Api's)
Editor fields intialization
Editor Presubmit event
and how to update that row with the updated data from the server?
I'm still not clear, you didn't answer my questions. If you want to send data to the server in the
preSubmit
, then the second arg isdata
(you've got it wrong in your code above, see the link) - you can values to that and they'll be accessible on the server. The example on the reference page is doing something similar (there it's changing a value, you can add one too).I am sorry I am not getting what you are asking.
In
preSubmit
the second argument is obj I mentioned.I can see the edited data and the obj data looks like below.
In the Controller of MVC
In the obj object in Controller all the fields are null, data is not getting bind to that property.
Hope I answered your questions clearly.
Editor field initialization.
Data in server side is null for all the fields, referred
ajax.data
Submit data as JSON in the request body is not workingIf you look at the network inspector in your browser, look at the Headers tab for the Ajax request that is being made - what does it show the parameters being sent to the server are?
My guess is there is some issue reading the values on the server-side, rather than a client-side issue. For that, you might need to ask on SO or similar, but I'd like to check that the data is actually being sent to the server first. If you have a screenshot of that network / headers tab, that would be great. If that isn't possible perhaps you can give me a link to the page.
Allan
Hi @allan , if I change the return to JSON.stringify(data.data[1]) ,it is working, but my question is index value is keep on changing for ex Row1 it is 1 for Row2 it is 2.
Somewhat surprised by that. Does it work on all rows? The inner
data
object is keyed by the id property of the row(s) being edited. I would have expectedObject.keys()
or similar to be required to determine which rows were edited.Allan
I used like this to submit the data to server, yes @allan it is working.
The documentation here shows what Editor expects in return from the server to update the table.
Allan
Thank you @allan , I made changes like below in Wep Api now I am able to get the response same like it is mentioned in the documentation.
Again a new problem after the response from the Web api to
submitComplete
the row in the UI is disappearing.Perhaps you can show me the JSON that your server-side script is returning please? It sounds like it isn't returning what Editor expects.
Allan
@allan this solved my problem.
@Abhishek K S hey mate, i'm having the same issue. Where do you put the Editor postSubmit event? At what part of the code.
@SotirPleqaj , apologies for the late reply, I am not very active in this forum. Below is the answer to your question