Renderuj dynamiczne komponenty w kolumnie ExtJS 4 GridPanel za pomocą Ext.create
Mam GridPanel ExtJS (4.0.7), który zapełniam ze sklepu. Wartości wyświetlane w kolumnie GridPanel muszą mieć inny widok w zależności od typu danych znajdujących się w rekordzie.
Ostatecznym celem jest nagrywanie z wartością „podwójną” lub „całkowitą” dla rekordutype
właściwość przedstawia suwak dla użytkownika, który może dostosować, a typ „ciągu” po prostu renderuje tekst tylko do odczytu.
W tym celu stworzyłem niestandardową kolumnę. Sprawdza typ w rendererze i określa, co należy renderować.
Mam „ciąg” działający dobrze z poniższym kodem, ale zmagam się z tym, jak mogę dynamicznie tworzyć i renderować bardziej skomplikowaną kontrolę suwaka w kolumnie.
Ten uproszczony przykład próbuje tylko renderowaćPanel
z kontrolą daty, tak jakbym mogła to zrobić, mogę wymyślić resztę rzeczy z suwaka.
Ext.define('MyApp.view.MyColumn', {
extend: 'Ext.grid.column.Column',
alias: ['widget.mycolumn'],
stringTemplate: new Ext.XTemplate('code to render {name} for string items'),
constructor: function(cfg){
var me = this;
me.callParent(arguments);
me.renderer = function(value, p, record) {
var data = Ext.apply({}, record.data, record.getAssociatedData());
if (data.type == "string") {
return me.renderStringFilter(data);
} else if (data.type == "double" || data.type == "integer") {
return me.renderNumericFilter(data);
} else {
log("Unknown data.type", data);
};
},
renderStringFilter: function(data) {
// this works great and does what I want
return this.stringTemplate.apply(data);
},
renderNumericFilter: function(data) {
// ***** How do I get a component I "create" to render
// ***** in it's appropriate position in the gridpanel?
// what I really want here is a slider with full behavior
// this is a placeholder for just trying to "create" something to render
var filterPanel = Ext.create('Ext.panel.Panel', {
title: 'Filters',
items: [{
xtype: 'datefield',
fieldLabel: 'date'
}],
renderTo: Ext.getBody() // this doesn't work
});
return filterPanel.html; // this doesn't work
}
});
Moim problemem jest, jak mogęExt.create
komponent i czy ma on być renderowany w kolumnie w panelu siatki?