| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- Ext.define('saas.util.GridUtil', {
- BaseUtil: Ext.create('saas.util.BaseUtil'),
- /**
- * 获取grid列配置
- * @param grid grid组件
- * @param url 请求url
- */
- setColumns: function(grid, url) {
- this.BaseUtil.request({url})
- .then(function(response) {
- var columns = Ext.decode(response.responseText);
- var fields = columns.map(column => column.dataIndex);
- var store = Ext.create('Ext.data.Store', {
- fields,
- });
- if(grid.showIndex) {
- columns.unshift({ xtype: 'rownumberer' });
- }
- grid.reconfigure(store, columns);
- grid.fireEvent('afterSetColumns', grid, columns);
- })
- .catch(function(response) {
- // something...
- });
- },
- /**
- * 获取grid数据
- * @param grid grid组件
- * @param url 请求url
- */
- loadData: function(grid, url) {
- this.BaseUtil.request({url})
- .then(function(response) {
- var data = Ext.decode(response.responseText);
- grid.getStore().loadData(data);
- grid.fireEvent('afterLoadData', grid, data);
- })
- .catch(function(response) {
- // something...
- });
- }
- });
|