Problem with select column.
Problem with select column.
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
Per the forum rules, please link to a test case showing the issue.
Allan
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?
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
The example did help.
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.
If you are using Editor for this, you need to use the
update
method of theselect
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