How to place all similar columns adjacent while copying one set of columns to other in datatable

Hi,

I have two datatables under two tabs.
The second table has same columns as the first table plus few extra columns.

While I am copying one set of columns from the first table to the second, I want all the editable columns from both tables to be placed in adjacent manner on the RHS in the second table.

How do I achieve that ?

Snippet: Code Snippet

Thanks.

Hi,

I have managed to re-arrange the columns of the second datatable this below way, however any better and webix specific approach is always good to have:

var uneditable_cells = [];
var editable_cells = [];
  for (var i in mycols2) {
    var column_header = mycols2[i];    
    if(column_header.hasOwnProperty('editor')) {
      editable_cells.push(column_header);
    } else {
      uneditable_cells.push(column_header);
    }

  }

mycols2 =  uneditable_cells.concat(editable_cells);

It’s a correct approach.
Columns have to be added to the datatable as an array that was not initialized before (that’s why webix.copy is required).

The only suggestion is in the usage of webix.copy.
If you have any config/data object, such as

var myCols = [ ... ];

It can be used in the datatable config as columns:webix.copy(myCols) so that the original myCols won’t be affected by the component init and can be re-used in that way as many times as you need in any part of the further code.

Thanks Listopad for your inputs.