lundi 13 octobre 2014

Migrate from ComponentColumn to widgetcolumn

In Ext 4, we use componentcolumn (http://ift.tt/1z3GbvD) to render Ext component in a grid cell.

In Ext 5, the built-in widgetcolumn have the same abaility to do so.

This is an example of ComponentColumn:



Code:



{
dataIndex: 'age',
xtype: 'componentcolumn',
renderer: function(value, m, record) {
if (value < 30) {
return {
xtype: 'myWidget1';
};
} else {
return {
xtype: 'myWidget2';
};
}
}
}



This is an example of widgetcolumn :


Code:



{
xtype: 'widgetcolumn',
widget: {
xtype: 'container',
},
onWidgetAttach: function(widget, record) {


var items = [];
if (record.get('age') < 30) {
items.push({
xtype: 'myWidget1'
})
} else {
items.push({
xtype: 'myWidget2'
})
}
widget.removeAll();
widget.add(items);
}
}

Question:

componentcolumn can determine which xtype to render on renderer function (run time) while widgetcolumn must assign a static xtype at compile time.

In this case, when using widgetcolumn, it create a container which consist of a widget.

When using componentcolumn, it create the widget directly. (fewer layers of components)

So my question is: can widgetcolumn determine which xtype to render at run time just like componentcolumn?



Migrate from ComponentColumn to widgetcolumn

Aucun commentaire:

Enregistrer un commentaire