Loading nested datatables prior to opening editor window

Loading nested datatables prior to opening editor window

ubdpetersubdpeters 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?

Answers

  • allanallan Posts: 63,230Questions: 1Answers: 10,416 Site admin

    This blog post does basically that. It doesn't use the datatable field type, but the principle is exactly the same - you use dependent() to watch for changes on whatever variable is causing the list of options in the table to change.

    Regards,
    Allan

  • ubdpetersubdpeters Posts: 26Questions: 8Answers: 0

    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);
    }

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    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

  • ubdpetersubdpeters Posts: 26Questions: 8Answers: 0

    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);
    }

  • ubdpetersubdpeters Posts: 26Questions: 8Answers: 0

    I figured out my problem.
    I needed to call:
    var tableVar = editor.field('datatableFieldName').dt();

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Yep, that's it, glad you got it sorted.

    Colin

This discussion has been closed.