1.描述:在工具栏中输入实验室别名和数据采集范围之后调用另外一个controller。两个不同controller之间调用问题。
当实验室别名和时间改变 的controller中
this.fireEvent('acquisitioncontrollersuccess'+responseText);
在另一个controller中写监听
listen: { controller: { 'acquisition-controller': {上一个controller的别名。 acquisitioncontrollersuccess: 'specimenIndexData' 监听要调用的方法。 } } },
2.加载假的json数据。
specimenIndexData: function (labName,dataAcquisition) { var deferred = Ext.create('Ext.Deferred'); var store = this.getViewModel().getStore('specimenNumber'); 得到store。 var meStore = store; store.clearFilter(true); var filter = Ext.create('Ext.util.Filter', { property: 'labName', value: labName }); store.addFilter(filter, true); var filter1 = Ext.create('Ext.util.Filter', { property: 'dataAcquisition', value: Ext.Date.format(dataAcquisition, 'Y-m') }); store.addFilter(filter1, true); meStore.proxy.url='./dataacquisition/specimennums'; 向后台发送请求 如果小于0 就加载假json store.load({ callback: function (records, operation, success) { var responseText = Ext.decode(operation.getResponse().responseText); if (!success) { Amili.amili.FlyTip.fly(responseText.title, responseText.message, responseText.category); }else{ if (records.length <= 0) { meStore.getProxy(); var url = Amili.getApplication().paths['Amili.dataacquisition'] ? './dataacquisition/data/SpecimenIndexData.json' : './webjars/dataacquisition/data/SpecimenIndexData.json'; meStore.proxy.url = url; meStore.load(); } deferred.resolve(records); } }, scope: this }); return deferred.promise; }
---------------------------------------------------------------------------------
specimenNumberEdit: function (editor, context, eOpts) { var id = this.getViewModel().get("labId"), collectTime = this.getViewModel().get("collectDate"); if (context.record.dirty) { if (id === null || id.replace(/\s/g, "").length === 0 || collectTime === null) { Amili.amili.FlyTip.fly('警告', '请输入实验室名称或选择数据采集范围', 'warning'); return; } var records = context.store.getData(); if (records.length > 0) { var list = []; for (var i = 0; i < records.length; i++) { var newObject = {}; newObject.collectNum = records.items[i].data.collectNum; newObject.collectType = records.items[i].data.collectType; newObject.memo = records.items[i].data.memo; list[i] = newObject; } Ext.Ajax.request({ url: './dataacquisition/specimennums_update', dataType: 'json', method: 'POST', params: { jsonData: Ext.encode(list), id: id, collectTime: Ext.Date.format(collectTime, 'Y-m') }, success: function (response, options) { context.record.commit(); var responseText = Ext.decode(response.responseText); Amili.amili.FlyTip.fly(responseText.title, responseText.message, responseText.category); }, failure: function (response, options) { var responseText = Ext.decode(response.responseText); Amili.amili.FlyTip.fly(responseText.title, responseText.message, responseText.category); } }); } } },
某个单元格不能编辑
beforeedit: function (editor, context, eOpts) { if (context.field == 'collectType' && context.record.data.state == 1) { return false; } }
删除图标 状态为1显示,状态为0不显示图标。
items: [{ text: '删除', iconCls: 'list-del', tooltip: '删除', handler: 'onRemoveClick', hidden: false, getClass: function (v, metadata, record) { if (record.data.state == 1) { return 'x-hidden'; } return 'list-del' } }]