Update datatable with select field
Update datatable with select field
yu yen kan
Posts: 65Questions: 31Answers: 0
I have a object like
function a(opts)
{
this.opts = opts;
}
in my editor I use it as
var test= new $.fn.dataTable.Editor( {
table: "#test",
idSrc: 'id',
fields: [ {
label: "Test:",
name: "opts.id",
type: "select",
ipOpts: getData()
}]
});
and the datatable display it as
var testTable = $('#test).DataTable({
dom: "Bfrtip",
data: [ getDataList() ],
columns: [ { data: 'opts.label', title: "opts label" } ],
select: true,
buttons: [
{ extend: "create", editor: test},
{ extend: "edit", editor: test},
{ extend: "remove", editor: test}
]
});
when I edit the data, the display will become null, how can I replace opts.label as the select label and opts.id as select value?
This discussion has been closed.
Answers
What is
getData()
returning? Can you show me that code please?Allan
Ah - I see the issue. The problem is that you are using a local table editing, editing data which is set to the DataTable, but the extra information that is not in the edit cannot be read by the DataTable.
Consider the Ajax join examples for Editor - there are two bits of information returned by the server for a joined field after an edit:
You have only the value here since you are not making an Ajax request to the server to get the data for the joined fields.
You would need to use
postSubmit
to add the label to the data that will be used to populate the record.Generally I would not recommend using local editing for joined data, because of exactly this issue.
Allan
If not using local editing, any other method to use ?
Ok I reopen this one @allan .
I'm in the same case. Local editing with joined data.
I'm trying to update the table after edit the select field with
postSubmit
orpostEdit
but how can I get the label corresponding to the new value?
I found this example http://live.datatables.net/layonado/2/edit
Working fine, even with inline editing