use different data source?

use different data source?

loukinglouking Posts: 259Questions: 52Answers: 0
edited November 2018 in Editor

I have my own visualization of a table that isn't using datatables for the display. I have created a standalone editor instance, and I want to load the data from my visualization into the edit form when the form is opened.

The "row" is clicked on in my visualization, and from the click handler I have access to an object which looks just like an object which would normally be returned in an editor submit response.

I'm not quite sure the easiest way to initialize the form with this object's data. I was thinking to use multiSet() but it looks like that is expecting row ids in the inner-most nesting.

Looking at Editor.prototype.edit, it looks like it is calling _dataSource() to initialize the form, but I can't see how to get in the middle of that.

Answers

  • loukinglouking Posts: 259Questions: 52Answers: 0

    hmm, I see a dataSource option under Editor.models.settings which looks like it would help, but don't see the documentation on how to use it.

  • loukinglouking Posts: 259Questions: 52Answers: 0

    This was simpler than I thought. I was able to use the following code to achieve the goal.

    Note I used lodash for the _.get() because the fields may be nested.

          editor.title('Edit entry').buttons('Update').edit();
          $.each( editor.order(), function( i, field ) {
            editor.set( field, _.get(event.data, field ) );
          })
    
This discussion has been closed.