checkboxes not populated in editor dialog

checkboxes not populated in editor dialog

sagimannsagimann Posts: 18Questions: 9Answers: 0

hi,
I have set up a checkbox field "os" with 3 checkboxes: ios, android, windows (same name and label), and I am having trouble reading that info later back into the editor.

Initially, when I perform the "create" action, I need to change the structure, so I set the "ajax": customSubmit editor option and rebuild the json based on the checkbox values. In my case, the 3 checkboxes of the "os" field are changed to three different json properties: "is1", "is2", "is3", and the "os" property is removed. so far so good. DT renders this correctly in the table.

But when I want the editor to read the altered data back into the editor dialog (edit action), I don't know where I can make the opposite operation, and convert the 3 separate json props into a single "os" array prop... this causes the editor dialog to show empty checkboxes - not checked appropriately...

As an attempt to workaround it, I artificially add the "os" field right after the data is read from the server (I do it using a custom ajax function), so during the ajax call, I have code similar to:
object.os = []
if object.is1 then object.os.push("is1");
if object.is2 then object.os.push("is2");
if object.is2 then object.os.push("is3");
return object to DT

My q is simple: is that a reasonable solution to the problem? Or is there some better way to do the mapping between how DTE structures checkbox data and how my server expects it?

pls advise.
tnx

This discussion has been closed.