Multiple editors

Multiple editors

xfloydxfloyd Posts: 35Questions: 12Answers: 1

Hello,
What would be the best way to pass data to additional editor, I'm understanding that
table: "#datatable_edit_employees",
is what tells main editor where to find data to populate form. But if I have another editor on the same page is there a way to tell that editor to get data from different source, let's say JavaScript object or array.
I have a table where I have typical columns and editor works great, but I want on the same page another editor that saves different fields not related to that table.
Regards,

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    What is the second Editor related to? A different DataTable, or perhaps a standalone form?

    Allan

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1

    Standalone. Allan seriously are you trying to create a programming framework/language out of that datatables. Love it, stand alone seem to be exactly what I'm after.

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1
    edited August 2017

    Standalone works great and all. The only problem that I can not solve is how to update/refresh editors data after submitting it to server, which works well. I'm using set() to set all the columns, but how do set it again at run-time for that editor to apply submitted changes?
    Here is that code:

    var editor_data = {"co_code":"555","allowed_taken_position_number":"0","reset_year":"","rate_type":""};
    
    ...
    
    { text: 'ADP Defaults', action: function() {
        editor9.edit('adp_defaults', false, {
            title: 'Edit ADP Defaults',
            buttons: 'Save'
        }).set(editor_data);
                .open();
    }},
    
  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Yes, its funny how complex something as simple as a table and a form can become :).

    If you aren't using the attributes such as data-editor-field to tell Editor where to get and set values from, you need to do it directly yourself. That would be done in the postEdit event, which will give you access to the data that was edited - e.g.:

    editor.on( 'postEdit',  function( e, json, data ) {
      $('#myElementToUpdate').html( data.myProperty );
    } );
    

    The data-editor-field attribute more or less does the same thing - just with added magic (to use Apple terminology...).

    Allan

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1
    edited August 2017

    Since I do not display that data anywhere in the DOM just edit, I went with turning "editor_data" variable into a function.

    .set(function() { return editor_data })
    

    Now on postEdit I can manipulatethat variable and next time I edit, changes get applied. Without any magic.
    Thanks Allan

This discussion has been closed.