Problem with select column.

Problem with select column.

dsanchezdsanchez Posts: 5Questions: 1Answers: 0
edited January 2016 in Free community support

I am new to DataTables and I am having a problem using a select column in the table. The select column, rtdDiagnoses, shows the select with the choices when I am in the cell. When I select a value it is not being displayed in the cell when I leave it. Any idea what I am doing wrong? Any help is appreciated.

var editor;

var i = 0;

var dataSet = [{

 "DT_RowId": i++, 
 "index": i, 
 "units": "System Architect", 
 "rtdDiagnoses": "" 

}, {

 "DT_RowId": i++,
 "index": i,
 "units": "System Architect",
 "rtdDiagnoses": "t.nixon@datatables.net"

}];

$(document).ready(function() {

editor = new $.fn.dataTable.Editor({

 table: "#tbl-claim-lines",
 fields: [{
    label: "Index:",
   name: "index"
 }, {
   label: "Units:",
   name: "units"
 }, {
   label: "Related Diagnoses:",
   name: "rtdDiagnoses",
   type: "select",
   ipOpts: [
                { label: "Type1", value: "1" },
                { label: "Type2", value: "2" },
                { label: "Type3", value: "3" },
                { label: "Type4", value: "4" };
            ]
   }
   ]

} );

$('#tbl-claim-lines').on('click', 'tbody td.is-editable', function(e) {

 editor.inline(this);

});

$('#tbl-claim-lines');

var dt = $('#tbl-claim-lines').DataTable({

data: dataSet,
columns: [
    { title: '#', data: 'index' },
    { title: 'Units', data: 'units', 'class': 'is-editable' },
    { title: 'Related Diagnoses', data: 'rtdDiagnoses', 'class': 'is-editable', editField: "rtdDiagnoses" }
],
buttons: [
    { extend: 'create', editor: editor },
    { extend: 'edit',   editor: editor },
    { extend: 'remove', editor: editor }
]

});

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Per the forum rules, please link to a test case showing the issue.

    Allan

  • dsanchezdsanchez Posts: 5Questions: 1Answers: 0

    The link to a test case is http://live.datatables.net/wibihesa/1

    Is there a way to make the last column a drop down list? I was using the editor to do this. Is there a way I can use the editor in live.datatables.net?

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    You could use an approach something like in this example. It uses checkboxes rather then select elements, but I don't see why a select element couldn't be used.

    Allan

  • dsanchezdsanchez Posts: 5Questions: 1Answers: 0
    edited January 2016

    The example did help.

  • dsanchezdsanchez Posts: 5Questions: 1Answers: 0

    I am getting very close to solving this. I have a select element as a column in the table. The problem is I cannot select anything in the list. What am I missing? An example can be found at
    http://live.datatables.net/wibihesa/6/edit

    Thanks.

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    If you are using Editor for this, you need to use the update method of the select field type in order to populate the list. Unfortunately you can't just write to the DOM since Editor needs to know what the values actually are.

    Allan

This discussion has been closed.