Extjs学习总结---RowExpander 的异步调用
来源:互联网 发布:彩虹六号围攻优化 编辑:程序博客网 时间:2024/06/06 19:03
RowExpander是Extjs中grid的一个插件,可以在一行下再展现数据。实现了非常方便的parent-detail的效果。
1.加入mousedown事件处理
- if (Ext.ux.grid.RowExpander) {
- Ext.apply(Ext.ux.grid.RowExpander.prototype, {
- getDataFn : null,
- onMouseDown : function(e, t) {
- if (t.className == 'x-grid3-row-expander') {
- e.stopEvent();
- var row = e.getTarget('.x-grid3-row');
- var viewRow = row;
- if (typeof viewRow == 'number') {
- viewRow = this.grid.view.getRow(viewRow);
- }
- var record = this.grid.store
- .getAt(viewRow.rowIndex);
- if (!record.data.checkSignerInvoicess) {
- var mark= new Ext.LoadMask(Ext.getBody(), {
- msg : 'Loading data...',
- removeMask : true
- });
- mk.show();
- this.getDataFn (record, this,
- function(expander) {
- // 展开该行
- expander.toggleRow(viewRow.rowIndex);
- mark.hide();
- });
- return;
- }
- this.toggleRow(row);
- }
- }
- });
- }
2.制作获取数据函数
- function GetInvoices(record, expander, callback) {
- Ext.Ajax.request( {
- url : 'getDetailInvoices.json',
- params : {
- 'chkNo' : record.data.chkNo,
- 'vendorNo' : record.data.vendNo
- },
- success : function(response) {
- var data = Ext.decode(response.responseText);
- if (!data.success) {
- showError(data.message, checkBooks);
- return true;
- }
- // 设置模板中所需要的record数据,并展开该行
- record.data.checkSignerInvoicess = data.records;
- record.commit();
- if (callback) {
- callback(expander);// 一定要回调该函数,否则不能展开
- }
- },
- failure : function() {
- if (callback) {
- callback(expander);
- }
- }
- })
- }
- ;
3.制作expander
- var expander = new Ext.ux.grid.RowExpander(
- {
- tpl : new Ext.XTemplate(
- '<div class="x-grid-group-title" style="margin-left:10%">',
- '<table class="x-grid3-row-table" cellspacing="0" cellpadding="0" border="0" >',
- '<thead>',
- ' <tr class="x-grid3-hd-row"><td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >seqNo</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >status</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >amt</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >discAmt</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >payAmt</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >vendNo</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >cashAcctCurrCd</td> <td class="x-grid3-hd x-grid3-cell x-grid3-td-11" >altVendNo</td> </tr>',
- '</thead>',
- '<tpl for="checkSignerInvoicess">',
- '<tr><td>{seqNo}</td> <td>{status}</td> <td>{amt}</td> <td>{discAmt}</td> <td>{payAmt}</td> <td>{vendNo}</td> <td>{cashAcctCurrCd}</td> <td>{altVendNo}</td></tr>',
- '</tpl>', '</table>', '</div>'),
- lazyRender : true,
- getDataFn : GetInvoices
- // 注册回调函数
- });
4.使用expand
- //column中
- var columns = new Ext.grid.ColumnModel( [
- new Ext.grid.RowNumberer(), sm, expander, {
- //grid中
- var grid = new Ext.grid.GridPanel( {
- title : 'Payment Information',
- renderTo : 'my-tabs',
- store : initalStore,
- cm : columns,
- sm : sm,
- plugins : expander,
5.效果
- Extjs学习总结---RowExpander 的异步调用
- Extjs学习总结---RowExpander 的异步调用
- Extjs RowExpander的扩展,支持异步加载
- ExtJS 插件 --- RowExpander 格式化模板的数据
- 关于Extjs 中 RowExpander控件的默认展开问题
- Extjs学习总结之26treepanel异步加载
- ExtJS4 表格的嵌套 rowExpander
- 关于.NET异步调用的初步总结
- Extjs学习总结---Date的处理
- 异步调用总结
- 异步调用总结
- Extjs学习总结
- EXTJS学习总结(A)
- Extjs 学习总结
- ExtJs 学习问题总结
- extjs学习总结
- ExtJs学习总结(2)
- EXTJS——ext.grid.RowExpander模板数据刷新问题
- android中图片的一些操作小片段代码
- http状态码
- Windows Socket 最大连接数
- 黑马程序员_IO流入门讲解
- 多浏览器支持之 IE11【让程序支持IE11】
- Extjs学习总结---RowExpander 的异步调用
- HDU 4666 Hyperspace
- HQL具体用法
- Extjs学习总结---RowExpander 的异步调用
- .NET Remoting
- IAR MCS-51 v7.51A 软件注册机下载
- 类对象创建时占用内存
- 学Android开发啦啦啦啦啦啦啦啦啦
- 黑马程序员-Java多线程同步器CyclicBarrier