任何人都可以帮我解决网格行扩展器与子网格.获得纯文本的价值可以正常工作.
有没有什么办法可以在Grid中创建一个Grid来从JSON数据中获取值?
我想用MVC架构创建这个结构..请提供一些想法或解决方案.
谢谢
Ext.define('CSApp.view.ContentGrid',
{
extend: 'Ext.grid.Panel',
store: 'Details',
width: 840,
height:45,
initComponent: function()
{
this.columns = [
{header: 'TASK ID', dataIndex: 'taskID', flex:1},
{header: 'ITEM', dataIndex: 'name', flex:1},
{header: 'EXISTING VALUE', dataIndex: 'value', flex:1},
{header: 'NEW VALUE', dataIndex: 'newValue', flex:1}];
this.callParent(arguments);
}
});
Run Code Online (Sandbox Code Playgroud)
我有一个类似的场景:拥有自己的记录数据(地址,电话,帐户余额等)的客户列表,每个客户也有一个帐户,其中包含一组"付费"项目.换句话说,我需要一个可以行扩展的客户网格来打开他们自己的"帐户网格",显示一个项目网格,其中包含有关项目的相关数据,他们支付的金额等.
我精简了一堆不相关的配置和其他代码,但这里是我用于"外部"网格的视图示例:
Ext.define('MyApp.view.CustomerGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.customergrid',
requires: [
'Ext.ux.RowExpander'
],
title: 'Customer Grid',
plugins: [{
ptype: 'rowexpander',
pluginId: 'rowexpander',
selectRowOnExpand: true,
// this gives each row a unique identifier based on record's "acct_no"
rowBodyTpl: [
'<div id="AccountGridRow-{acct_no}" ></div>'
],
// stick a grid into the rowexpander div whenever it is toggled open
toggleRow: function(rowIdx) {
var rowNode = this.view.getNode(rowIdx),
row = Ext.get(rowNode),
nextBd = Ext.get(row).down(this.rowBodyTrSelector),
hiddenCls = this.rowBodyHiddenCls,
record = this.view.getRecord(rowNode),
grid = this.getCmp(),
acctNo = record.get('acct_no'),
targetId = 'AccountGridRow-' + acctNo;
if (row.hasCls(this.rowCollapsedCls)) {
row.removeCls(this.rowCollapsedCls);
this.recordsExpanded[record.internalId] = true;
this.view.fireEvent('expandbody', rowNode, record, nextBd.dom);
if (rowNode.grid) {
nextBd.removeCls(hiddenCls);
rowNode.grid.doComponentLayout();
rowNode.grid.view.refresh();
} else {
// this is the store for the inner grid
Ext.create('Ext.data.Store', {
model: 'MyApp.model.Account',
proxy: {
type: 'ajax',
url: 'customers',
reader: 'json'
extraParams: {
account: acctNo
}
},
autoLoad: {
callback: function() {
// create the inner grid and render it to the row
nextBd.removeCls(hiddenCls);
var grid = Ext.create('MyApp.view.AccountGrid', { // <-- this is my "inner" grid view
renderTo: targetId,
store: this,
row: row
});
rowNode.grid = grid;
// I didn't want to listen to events from the inner grid
grid.suspendEvents();
}
}
});
}
} else {
row.addCls(this.rowCollapsedCls);
nextBd.addCls(this.rowBodyHiddenCls);
this.recordsExpanded[record.internalId] = false;
this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
}
}
}],
columns: [/* a bunch of column configs for the outer grid... */],
store: Ext.getStore('StudentList') // <-- the outer grid store
});
Run Code Online (Sandbox Code Playgroud)
基本上我只是覆盖了toggleRow将另一个grid(MyApp.view.AccountGrid)粘贴到rowexpander div中的函数.
这非常好,应用程序现已完成.
我有缓存对象中内部"帐户"网格的数据,以便ajax在50 - 100毫秒内返回.如果你有一些长查询来获取内部网格数据,我可以看到这是不可行的.
| 归档时间: |
|
| 查看次数: |
7619 次 |
| 最近记录: |