Data is duplicated, ie in addition to saving the data sen
Data is duplicated, ie in addition to saving the data sen
klermann
Posts: 277Questions: 67Answers: 1
Hello. In the editor when I click the button to save the form data, the form is sent and saved, but in my table the data is duplicated, ie in addition to saving the data sent and duplicate them in the table all other items In the table are also duplicates, as the table updates From the order of ex: 1, 2, 3, 4, 5, 6 looks like this: 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6 What do I do to prevent this?
This discussion has been closed.
Answers
Can you show me the JSON that your server is returning when you press the submit button please? If you could also show me the Javascript configuration for your Editor, that would be useful.
Allan
In my database the data is not duplicated
.
My JSON:
code editor:
That JSON is what is returned in response to the edit or create action? If so, that is the issue - since it should only be returning the JSON for the newly created row or the edited row(s).
Full documentation for the client / server interchange is available here.
Allan
Allan, now I only have the object created and returned by json, but it was not updated without date, ie I created the object and the server returned me the json with the created object the datatable did not update, can you give me a suggestion?
Return of the object:
{"iTotalRecords":24,"iTotalDisplayRecords":0,"dataReceitas":null,"data":[{"id":176,"descricaoReceita":"Receita Demo","dataReceita":{"year":2017,"month":"AUGUST","dayOfMonth":8,"dayOfWeek":"TUESDAY","era":"CE","dayOfYear":220,"leapYear":false,"monthValue":8,"chronology":{"id":"ISO","calendarType":"iso8601"}},"valorReceita":5000.00,"receitaFixa":true,"receitaFixaQuantidade":null,"receitaFixaTempo":null,"repetirLancReceita":false,"repetirPorPeriodo":null,"pagamento":false,"addObservacao":"Add","tipoReceitas":[],"minhasContas":[],"etiquetas":[],"cor":null}]}
Can you give me a link to the page so I can help to debug it.
Thanks,
Allan
I am working locally with java, there is no way to pass a link, unfortunately!
I'm afraid there isn't a huge amount I can do to offer help in that case. I would need to be able to debug the page to understand what is going wrong as I don't see that in any of my examples, unless you are able to give me a link to an example which is showing the problem.
Allan
Hello Allan, I'm afraid the problem is when I create a new item for the datatable and it is not being updated automatically because the data value is as dataReceit. Would that be my problem?
Hello Allan,
I inserted this function to give a reload to the table, now how do I give a highlights in the row inserted in the table
editor.on( 'postCreate', function ( e, json, data) {
oTable.ajax.reload();
} );
If you are reloading the table, the old rows are being deleted and new rows being added - which means its actually very difficult to highlight the edited row since you need to find it in the table.
Instead, I would suggest you change the data being return from the edit action to that required by Editor. Specifically use
data
rather thandataReceit
and make it an array.Allan