Dynamic data field

Dynamic data field

YaniYani Posts: 24Questions: 7Answers: 0

Hi there. I'd like to have a field in the editor which would allow me to edit another field. I have the data option set to null, and use the render to calculate VAT by combining two other fields. Now I'd like to be able to edit this field, to calculate the original price by subtracting VAT.

I was thinking of something towards creating a custom editor.inline() field, but my javascript knowledge is limited. I've tried the editor events open and preOpen, but they are never called as I'm getting the following error:
Unable to automatically determine field from source. Please specify the field name

Would this be possible? Thanks in advance.

This question has an accepted answers - jump to answer

Answers

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

    This is going to be a little bit tricky I think, since Editor isn't designed to edit data that doesn't really exist. There are two options I can think of:

    1) Preformat the data (either client or server-side - it doesn't matter) before DataTables is given the data to display. The Preformat would basically just add the calculated value into the data set (in Editor's PHP or .NET libraries you could use a formatter for this).

    2) Set the columns.data option to be something invalid for the calculated column (rather than null - perhaps data:'notHere') and use that same value for the fields.name option in Editor. That will link the two. But I think you'll need to use val() to set the value on initEdit since Editor wouldn't be able to see the value as it doesn't exist!

    Allan

  • YaniYani Posts: 24Questions: 7Answers: 0

    Thanks a lot Allan! I got it working

This discussion has been closed.