DataTables Editor Select List - Set Selected Attribute

DataTables Editor Select List - Set Selected Attribute

jwrightspjwrightsp Posts: 12Questions: 1Answers: 0
edited August 2014 in Editor

Is there away to set the "selected" attribute for an option in the ipOpts array when doing an add new process? Right now the field is defaulting to the first element but that is not optimal for my scenario.

Thanks!

John

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited August 2014 Answer ✓

    Hi John,

    You can't set the default value in the ipOpts array, but you can use the fields.def option to set the default. For example you might have something like:

                    label: "Priority:",
                    name:  "priority",
                    type:  "select",
                    def:  "3",
                    ipOpts: [
                        { label: "1 (highest)", value: "1" },
                        { label: "2",           value: "2" },
                        { label: "3",           value: "3" },
                        { label: "4",           value: "4" },
                        { label: "5 (lowest)",  value: "5" }
                    ]
    

    Regards,
    Allan

  • jwrightspjwrightsp Posts: 12Questions: 1Answers: 0

    Duh of course...

    Thanks for the quick reply Allan.

    John

  • chopstikchopstik Posts: 14Questions: 5Answers: 0

    But that's not quite the same, for a new row in the table, def: would be ideal to set a default value but if you're editing a select list your 'selected' attribute isn't present and a user would need to re-select the correct value instead of it already being selected.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    If you are editing a value and the value isn't in the select list, how would the user reselect it? Fundamentally if you edit an item, the value needs to be in the select list for it to be preselected on edit - I don't see how it could work otherwise?

    Allan

This discussion has been closed.