Loading nested datatables prior to opening editor window
Loading nested datatables prior to opening editor window
ubdpeters
Posts: 26Questions: 8Answers: 0
I'm using the collection example to display panels of items for a user to select from. Using the latest version of Editor, I've nested a Datatable into the editor. Each panel can have a different list of options in the datatable so I'd like to load the datatable after the user selects to edit the panel. The list of items in the datatable depends on the ID of the panel selected.
Are there any examples of this anywhere?
This discussion has been closed.
Answers
This blog post does basically that. It doesn't use the
datatable
field type, but the principle is exactly the same - you usedependent()
to watch for changes on whatever variable is causing the list of options in the table to change.Regards,
Allan
Can I manipulate the datatable field in the editor, like any other datatable, once I have an instance of it?
Here is what I am trying, but I get a can't read property "add" of undefined. Maybe I'm not establishing an instance of the field correctly?
editor.dependent( 'fieldName', function ( val )
{
var tableVar = editor.field('datatableFieldName');
tableVar.row.add(['1', '2', '3']).draw(false);
}
Yep, all the options and APIs call for a standard DataTables are available for Editor's DataTable type. By the question, I'm assuming you're having problems with that?
Colin
Yes, I'm getting a can't read property "add" of undefined. Maybe I'm not establishing an instance of the field correctly? Below is what I am trying to do after the user selects one of the options from 'fieldName'.
editor.dependent( 'fieldName', function ( val )
{
var tableVar = editor.field('datatableFieldName');
tableVar.row.add(['1', '2', '3']).draw(false);
}
I figured out my problem.
I needed to call:
var tableVar = editor.field('datatableFieldName').dt();
Yep, that's it, glad you got it sorted.
Colin