PDA

View Full Version : I need to place TreeStore data into Combobox



jimmyt1001
16 Aug 2014, 8:21 AM
Question. Please bare me because I am still new with extjs

I am trying to modify the output of an existing (GroupingTree) Tree store to something useful for the simple Combo box drop down because
the server side code is not returning data in the format that I need.
I created a UI Combobox in the code exmple shown below (my function code is commented out)
My store (a Tree store) is coming from a file named GroupingTree.js

but for some reason my function “getCustomStore” is not getting called so “customStore” is not being returned

My Function code

Ext.define('TV.view.configPanel.data.edit.analyticControls.CustomCaptionNew', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.customcaptionNew',
id: 'txtCustomCaption', //TODO: Remove ID - Check with QA
//Configuration
isFormattingControl: true,
/**
* Initialization of CustomCaption
* @method initComponent
*/
initComponent: function () {
var config = {
fieldLabel: 'Custom Caption as Dropdown',
blankText: TV.Global.ErrorMessages.CustomCaptionError,
name: 'Caption',
anchor: '100%',
allowBlank: false,
validateOnChange: true,
vtype: 'name',
minChars: 2,
typeAhead: 'true',
valueField: 'aggregationCode',
name: 'aggregationName',
/*store: new Ext.data.SimpleStore({fields:['aggregationCode','aggregationName'],
data: [['agg1','Cusip'],
['agg2','ISIN'],
['agg3','Sedol'],
['agg4','Group1'],
['agg5','Security'],
]})*/
store: getCustomStore()

};

Ext.apply(this, Ext.apply(this.initialConfig, config));
// Custom validator. For validating the entered caption for analytic.
Ext.apply(Ext.form.field.VTypes, {
name: nameValidator,
nameText: TV.Global.ErrorMessages.blankText
});
this.callParent();
}
var getCustomStore = function(){
/*var customCaptionStore = {};
var fields = ["aggregationName", "aggregationCode"];
var data = [{"name","Id"}];
//var tempStore = this.getStore(Store.GroupingTreeStore);
//alert("Got the proper store");
var fields = ['abbr', 'name'];
var data = [];
for (var x = 0; x < tempStore.getRootNode().childNodes[1].childNodes.length; x++){
data.push({name : tempStore.getRootNode().childNodes[1].childNodes[x].raw.text, abbr: tempStore.getRootNode().childNodes
[1].childNodes[x].raw.id});
}
var states = Ext.create('Ext.data.Store', {
fields:fields,
data:data
});
customCaptionStore = Ext.create('Ext.data.Store', {
fields:fields,
data:data
});
return customCaptionStore;*/
alert("Called debug");
return new Ext.data.SimpleStore({fields:['aggregationCode','aggregationName'],
data: [['agg1','Cusip'],
['agg2','ISIN'],
['agg3','Sedol'],
['agg4','Group1'],
['agg5','Security']
]});
};
});


Grouping tree.js store code
Ext.require('TV.model.AggregationTag');
Ext.define('TV.store.GroupingTree', {
extend: 'Ext.data.TreeStore',
filtered: false,
model: 'TV.model.AggregationTag',
proxy: {
type: 'direct',
directFn: ContainerConfigurationData.GetAggregations,
paramOrder: ['clientId', 'nodeToLoad', 'searchKey'],
paramsAsHash: true
},
autoLoad: false,
treeField: TV.constants.Constant.DataTabFields.GroupingsTreeColumnName,
//groupField: 'Category',
root: {
expanded: true,
loaded: true // Because groupfield is not defined, this is actually required for loading
}
});

Please help. This is killing me

chamacs
16 Aug 2014, 10:24 AM
This might help:

http://www.sencha.com/forum/showthread.php?182502-Tree-inside-a-ExtJS-4-combobox