0
我有一個按鈕,它可以計算我TreeStore中的某些項目。當我點擊它時,我想重新加載我的樹。但是現在,當我點擊一個項目來計算它時,在選定項目下創建另一個樹,然後重新加載一個樹。我如何爲這個問題編寫適當的代碼?如何在extjs中重新載入樹時單擊按鈕
這是我的功能時點擊計算按鈕:
'g-infitmformula #calculateFormula': {
click: function (sender) {
var selectedinfoIdList = Ext.ComponentQuery.query("g-infitmformula")[0].getSelectionModel().getSelection();
Ext.each(selectedinfoIdList, function (item) {
informationItemIds.push(item.data.id);
});
if (selectedinfoIdList.length > 0) {
Dufo.Func.loadMask(Ext.getBody(), true);
Ext.Ajax.request({
url: '/sis/rest/infoit/calculateFormula',
jsonData: {
infoItemStrings: informationItemIds
},
success: function (result, request) {
var data = Ext.JSON.decode(result.responseText).ReturnValue;
Ext.Msg.alert('', data.description);
Dufo.Func.loadMask(Ext.getBody(), false);
if (data.successful === true) {
// Ext.ComponentQuery.query('g-infitmformula')[0].store.reload();
Ext.ComponentQuery.query("g-infitmformula")[0].store.reload({
params: {
id: "root",
dtstart: dtstartVar,
dtend: dtendVar,
infitmcat: infitmcatVar
}
});
informationItemIds = [];
}
else {
informationItemIds = [];
Ext.Msg.alert('', data.description);
}
},
failure: function (result, request) {
Dufo.Func.loadMask(Ext.getBody(), false);
informationItemIds = [];
Ext.Msg.alert('', Ext.JSON.decode(result.responseText).ReturnValue.description || Dufo.ux.fa.jsonFormatFail);
}
});
} else {
Ext.Msg.alert('', Dufo.ux.fa.selectSomething);
}
}
}
這是我的店類,我想重裝:
Ext.define('Dufo.store.InformationItemsFormula', {
extend: 'Ext.data.TreeStore',
storeId: 'infitmformula',
model: 'Dufo.model.InformationItemsFormula',
autoLoad: false,
nodeParam: 'id',
clearOnLoad: true,
listeners: {
append: function (parent, child, index, eOpts) {
var me = this;
if (!child.isRoot()) {
child.set('leaf', child.get('isLeaf'));
if (child.data.children) {
var root = me.tree.treeStore.getRootNode();
child.data.children.forEach(function (test) {
var n = root.createNode(test);
child.appendChild(n);
});
}
}
}
},
proxy: {
type: 'ajax',
url: '/sis/rest/infitmval/gtinffmlitmval',
actionMethods: {
read: 'POST', create: 'POST'
},
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8'
},
jsonData: true,
reader: {
type: 'json',
root: function (o) {
if (o.ReturnValue) {
if(o.ReturnValue.detail.length) {
Ext.ComponentQuery.query("#calculateFormula")[0].setDisabled(false);
}else {
Ext.ComponentQuery.query("#calculateFormula")[0].setDisabled(true);
}
for (var i=0; i < o.ReturnValue.detail.length; i++) {
o.ReturnValue.detail[i].id = o.ReturnValue.detail[i].id + '-' +Dufo.store.TreeStoreIDGenerator.generateId();
}
return o.ReturnValue.detail;
}
}
}
}
});
我刪除它,但它不起作用。它會再次在我選擇的項目下創建另一棵樹。 –
請儘可能提供小提琴。 –