0

I have, for example, the following two objects:

object 1:

{

Id: 1,

Name: 'Menu 1',

MenuSuper: null

}

object 2:

{

Id: 2,
Name: 'Menu 2',
MenuSuper: { 
   Id: 1 
}

}

How can I manipulate grid to save, delete and select this one? My problem is 'MenuSuper'. How can use nested object with combobox in grid editor?

André Cristino
  • 95
  • 1
  • 14
  • 1
    Your example object only has one field, is it necessary to be an object instead of an additional field? Are you able to supply a small fiddle to illustrate your problem retrieving data? I'm not sure how the combobox plays in, or the purpose of the object in the grid. – Jaimee Mar 31 '17 at 19:25
  • As @Jaimee told, provide the fiddle to understand the problem. – Alexandre Neukirchen Apr 02 '17 at 17:23

1 Answers1

0

Sorry for my delay.

Here comes the fiddle: https://fiddle.sencha.com/#view/editor&fiddle/1tk3

But I alredy solved this issue.

When I put a combobox as an "editor" of an column, I also set a render for it.

For example:

 renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {     
                var combo = this.columns[colIndex].getEditor();
                var combostore = combo.getStore();              
                var dataIndex = combostore.findExact('id', value);
                var recordCombo = combostore.getAt(dataIndex);              
                return recordCombo.get('name');
            },  

In this code, I did not check if "value" is null and that is my mistake! This part must to be checked as below:

renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {      
                if(!value) return '';
                var combo = this.columns[colIndex].getEditor();
                var combostore = combo.getStore();              
                var dataIndex = combostore.findExact('id', value);
                var recordCombo = combostore.getAt(dataIndex);              
                return recordCombo.get('name');
            },  

The solution is quite simple! Thx!

André Cristino
  • 95
  • 1
  • 14