Something i don't understand about model and editor
Something i don't understand about model and editor
Hi Everyone
What i do :
I have my own data model and I inject it into the datatable/editor
My model contains lots of information, that aren't display, but is mandatory to some processes.
I am not interested in "dom storage", why should i use it when I have an object model, wich is faster than Dom queries ?
Now the problem : this is my model; raw injection, into the datatable,
After editing creneau.0.heureDebut, the internal model is affected and I lost the structure / data (Note, the data is correctly displayed using creneau.0.heureDebut, The section that is affected is outlined in red)
Here is an exemple of how I display data
{
data: 'creneaux.0.heureDebut',
orderable: false,
title: 'Début',
render: (heureDebut, type, row, meta) => {
return hourRenderer(heureDebut, type, row, meta);
}
},
I must use formatters because what is displayed to client is not what I have in my model. I also thought this would solve my problems
{
label: "heureDebut",
name: "creneaux.0.heureDebut",
type: 'datetime',
setFormatter: (value, field) => {
return formatHourMinute(value);
},
getFormatter: (value, field) => {
const creneau = this.getEventTracker().getOldRowData().creneaux[0];
const oldDate = new Date(creneau.heureDebut);
const newDate = manageHourMinuteField(oldDate, value); // avoid date modification and update trigger
return newDate;
},
format: 'HH:mm',
// displayFormat: "HH:mm", // Affect the attempted behaviour with a nasty way
// wireFormat: "HH:mm"
},
Best Regards,
Cédric
This question has an accepted answers - jump to answer
Answers
As far as I can tell you are only editing this:
And that is precisely what you get in your "internal model" after editing. You are replacing "creneaux" with what you are editing.
What would you expect? To me this looks like the correct behavior.
I know this is what I get, because I can display it like i want.
I expect this : Just replace the value name: "heureDebut" and not "erase" the whole object (See the two screenshots)
Can you show me the full Editor initialisation code you are using and any API calls you are making to it?
Thanks,
Allan