DataTables Inline Editor select does not select current value or submit first value

DataTables Inline Editor select does not select current value or submit first value

finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

datatable has keys inline editor option

keys: {
            editor:  editor 
              },

editor has submit (and works fine mostly)

                formOptions: {
                    inline: {
                        onBlur: 'submit',
                    }
                },
...

                 {
                        label: "MissingDNA",
                        name: "MissingDNA",
                        type: "select",
                        options: [
                          { label: "unknown", value: "" },
                          { label: "true", value: "true" },
                          { label: "false", value: "false" },
                          
                        ],
                        def: ""
                    },

the current value is displayed in the table, but when the inline edit is initiated, the selected in the select list is always the top value (not the current value). It does not matter if I do not define a default, or change the order of the options. The first option is always selected, and with this field (MissingDNA in this example) selecting the top option does not submit, no matter the current value.

same editor and this field works OK--including the fact that the current value is selected when inline edit is initiated:

                {
                        label: "Species",
                        name: "Species",
                        type: "select",
                        options: [
                          { label: "MAN", value: "4" },
                          { label: "BEAST", value: "5" }
                         
                        ]
                    },

I do not see a way to post an editor example in live.datatables.net

This question has an accepted answers - jump to answer

Answers

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    this has SAME symptoms

    {
                            label: "MyFlag",
                            name: "MyFlag",
                            type: "select",
                            options: [
                               { label: "true", value: "true" },
                               { label: "false", value: "false" }
                            ]
                        },
    
  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    the selected in the select list is always the top value (not the current value)

    That suggests that the value of the "MyFlag" field is not a string with the value of true or false.

    Can you show us the JSON you are using please?

    Allan

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    Same symptoms, after some mods. I updated the js to use values, rather than strings:

    {
                label: "MissingDNA",
                name: "MissingDNA",
                type: "select",
                options: [
                  { label: "unknown", value: null },
                  { label: "true", value: true },
                  { label: "false", value: false },
                  
                ],
                def: null
            },
    

    But still no love on edit:

    <select id="DTE_Field_MissingDNA">
      <option value="null">unknown</option>
      <option value="true">true</option>
      <option value="false">false</option>
    </select>
    

    The JSON:

    {
      "DataTableKey": "001A01",
      "Sex": "F",
      "MissingDNA": true,
      "LastSpecimenFlag": null
    }
    
  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Could you give me a link to the page showing the issue please? This should work correctly in Editor and I'd like to debug what is happening.

    Allan

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0
    edited November 2015

    The page is for a client, and is not publicly accessible.

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    allan,
    sent you a private message with a datatables live link. there you will find a datatables live that demonstrates the problem--I have disconnected calling my server ajax for update, but notice the incorrect selection on true/false columns. Please advise.

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    Update this live datatable with EDITOR references for css and js:

    http://live.datatables.net/wumagoha/1/edit?html,css,js,output

    to duplicate with simplified js and data

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    Answer ✓

    Hi,

    Awesome - thank you for the link.

    This is indeed a bug in Editor. It will correctly handle booleans for radio and checkboxes, but not for select elements unfortunately.

    I have the fix locally and can send you a copy of the file with the fix if you like. Should I use the e-mail address shown in your user name? Btw - do you want me to change your user name - a publicly visible e-mail address is a sure fire way of attracting spam!

    Regards,
    Allan

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    Yes allan please do both!

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    Please advise when 1.5.3-dev pushed to production?

    thank you, again!

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    By the end of the month.

    Allan

This discussion has been closed.