Why is the select display showing the value instead of the label?

Why is the select display showing the value instead of the label?

savannakingsavannaking Posts: 7Questions: 3Answers: 0
edited January 2015 in Free community support

I'm trying to use a select with inline editing. I have gotten this to display properly using the popup for editing, but I want it all to be inline and submit on blur. My data includes both an ID and a name for each dropdown item, which I have in an object that looks like { label: "blah", value: "blah" } etc.

However, in the DataTable the dropdowns are all being displayed with the ID instead of the label as the default value. I don't want users to see the label. I tried setting the editor field name to be the label and the DataTable column to be the value, which seemed to work for the popup but for inline editing I get the error "Uncaught Unable to automatically determine field from source. Please specify the field name".

My initializations look like this:

  editor = new $.fn.dataTable.Editor({
        ajax: 'url',
        table: '#table',
        idSrc: 'id',
        fields: [{
            label: "Location",
            name: "location_name", //this is where the problem is, I think
            type: "select",
            ipOpts: locationList
        }]})

   $('#table').dataTable({
        dom: "Tfrtip",
        "searching": false,
        "ajax": {
            "url": "url",
            "type": "GET"
        },
        "columnDefs": [
          { "visible": false, "targets": [8] }
        ],
        "columns": [
            { "data": "location_id" } 
        ])} 

If I change the DataTable to use the name, the display is correct, but I get the name submitted to the database instead of the ID, and I need the ID.

What should I do?

This question has an accepted answers - jump to answer

Answers

  • savannakingsavannaking Posts: 7Questions: 3Answers: 0

    Sorry for the formatting... I can't seem to get the Markdown to work.

  • savannakingsavannaking Posts: 7Questions: 3Answers: 0

    bump

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    Hi,

    Thanks for your question. I see your Editor trial license expired back at the start of January. How have you been getting on with the software?

    Regarding the error you are seeing, please refer to this page.

    Allan

This discussion has been closed.