function treeReLoaded(tree, url) { var TreeLoader = tree.getLoader(); //得到Ext.tree.TreeLoader TreeLoader.dataUrl = url; //更新数据源 var treeroot = tree.getRootNode(); //得到根节点 treeroot.reload(); //重新加载根节点 treeroot.expand(true, false); //展开树 }
function showBudget(success, ids,_store) { /// <summary>选择预算对话框</summary> /// <param name="success" type="Function"> /// 成功的回掉函数 格式:function(records) /// record:WOO_DEPARTMENT.ToJSON /// </param> /// <param name="ids" type="Array||String">已经选中的id</param> if (ids != null && Ext.isArray(ids)) {
ids = ids.join(); } var url = woo.constant.baseUrl + '/AjaxPage/OtherRequest/Budget.aspx?cmd=GetTree' +
'&CheckedIDs=' + ids + '&r=' + woo.util.getRandom(); var _treeloader = new Ext.tree.TreeLoader({
dataUrl: url, baseAttrs: { uiProvider: Ext.tree.TreeCheckNodeUI } }); var _root = new Ext.tree.AsyncTreeNode({ id: "root21", text: "选择预算", expanded: true }); var _tree = new Ext.tree.TreePanel({
lines: true, containerScroll: true, autoScroll: true, checkModel: 'cascade', onlyLeafCheckable: false, loader: _treeloader, root: _root }); var today = new Date(); var year = today.getFullYear(); var _form = new Ext.form.FormPanel({ layout: 'form', labelAlign: 'top', // layout: 'fit', bodyStyle: 'padding:20px', width: 500, labelAlign: "right", autoScroll: true, items: [ { xtype: "combo", fieldLabel:"年份", hiddenName: 'ContractFinanceType', value: year, //style: 'background: url(Resources/images/pen.gif) no-repeat 3px;padding-left:15px;', store: new Ext.data.SimpleStore({ fields: ['value', 'text'], data: [[year - 1, year - 1], [year, year], [year + 1, year + 1]] }), width: 200,//120 valueField: 'value', displayField: 'text', lazyRender: true, editable: false, typeAhead: true, triggerAction: 'all', mode: 'local', selectOnFocus: true, allowBlank: false, listClass: 'x-combo-list-small', listeners: { 'select': function (box, record, index) { var url2=url + "&year=" + record.get("value"); treeReLoaded(_tree, url2); //try{ // alert(_tree.loader); // alert(_tree.loader.dataUrl); // _tree.loader.dataUrl = url + "&year=" + record.get("value"); // //修改URL,注意,前面不要加'/'
// alert(_tree.loader.dataUrl); // // alert(_tree.loader.pagingModel); // //将加载模式修改为远程
// _tree.loader.pagingModel = 'remote'; // // alert(_tree.loader.pagingModel); //}catch(e){ // alert(e.name + ": " + e.message); //} //_tree.root = _root; //_tree.loader.load();//重新加载 //_tree.loader.pagingModel = 'local'; } } }, _tree ], buttons: [{ text: WooI18N.ModuleSystem.Setting.Workflow.Build.Shore, handler: function () { if (success) { var records = []; var b = _tree.getChecked(); for (var i = 0; i < b.length; i++) { records.push(b[i].id); } success(records); } _win.close(); } }, { text: WooI18N.ModuleSystem.Setting.Workflow.Build.Cancel, handler: function () { _win.close(); } }] }); var _win = new Ext.Window({ title: "选择预算", modal: true, layout: 'fit', width: 500, height: 500, closeAction: 'destroy', autoScroll: true, plain: true, resizable: false, constrainHeader: true, items: _form }); _win.show(); } |
|