Why Select box being selected without any action

Why Select box being selected without any action

ndtoan13ndtoan13 Posts: 8Questions: 3Answers: 0
edited March 2021 in Editor

Link to test case: http://199.241.138.6/demo/
Debugger code (debug.datatables.net): ugumes
Error messages shown: No
Description of problem:
I modified the Join example in the Inline-editing. The modification is not to use join table, the options of the select box is like this

{
    label: "Site:",
    name: "users.site",
    type: "select",
    options: [
      { label: "Admin", value: "1" },
      { label: "Mod", value: "2" },
      { label: "User", value: "3" }
    ]
},

To render the name instead of the value, I use:

{ data: "users.site",
    render: function(data, type, row, meta) {
      var m = "Select Site";
      if (row.users.site == 1) m = "A";
      if (row.users.site == 2) m = "B";
      if (row.users.site == 3) m = "C";
      return m;
    } 
},

It works fine if there is only one Select box, but if there are more, the other Select box (Role) will be selected automatically (and the first value is selected) when Select box (Site) is selected. I could not figure out what wrong did I make!

How to have the value of each Select box separately? please help!

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks for the link. It looks like you need a placeholder for the select box to allow an empty value to be the chosen one. See the select docs (specifically the various placeholder* options) for how that can be done.

    Allan

  • ndtoan13ndtoan13 Posts: 8Questions: 3Answers: 0

    Thank you alan, adding placeholer did work

This discussion has been closed.