gpt4 book ai didi

javascript - 如何将 TreeStore 数据放入 ComboBox 中

转载 作者:行者123 更新时间:2023-12-03 12:02:41 26 4
gpt4 key购买 nike

问题。请裸露我,因为我对 extjs 还很陌生

我正在尝试将现有(GroupingTree)树存储的输出修改为对简单组合框下拉列表有用的内容,因为服务器端代码没有以我需要的下拉格式返回数据。

我在下面所示的代码示例中创建了一个 UI 组合框(我的函数代码已被注释掉)

我的商店(树商店)来自名为 GroupingTree.js 的文件

但由于某种原因,我的函数“getCustomStore”没有被调用,因此“customStore”没有被返回。

在这个问题上我一直在用头撞墙。请帮忙

        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']
]});
};
});

我的 TreeStore 数据

            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
}
});

最佳答案

您的函数调用不是存储对象 -

-->  store: getCustomStore()

我会把它打破:

首先定义您的商店 -var store = new Myapp.data.TreeStore({ storeId: 'treeStore', 自动加载:“真”, 模型:'Myapp.TreeModel',

proxy: {
type: 'ajax',
actionMethods: {create: 'POST'},
url: '../include/some_json_block.php',
reader: {
type: 'json',
root: 'nodes',
idProperty: 'id'
}
},
root: {
text: 'Some Root Vx',
id: '0',
expanded: true
}

});

然后将商店放置在面板中--var treePanel = new Myapp.tree.Panel({ title: '面板树管理器', id: 'mainTreePanel', 宽度:200, 高度:20, 商店: 商店, rootVisible:true,

也许这有帮助......

关于javascript - 如何将 TreeStore 数据放入 ComboBox 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25343679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com