看图,我想根据左边的表格记录,更改红色的部分为 ComboBox ,TextField,或者 DateField , 有什么好的方法 ?
3条回答 默认 最新
- zhoujuan520 2009-03-22 11:36关注
[color=red]帮你做出来了.或下面测试通过,原理就这样了[/color]
[code="html"]
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
网络狗盘
<br> /*<br> * Ext JS Library 2.2.1<br> * Copyright(c) 2006-2009, Ext JS, LLC.<br> * <a href="mailto:licensing@extjs.com">licensing@extjs.com</a><br> * <br> * <a href="http://extjs.com/license">http://extjs.com/license</a><br> */</p> <pre><code> Ext.onReady(function(){ Ext.QuickTips.init(); // turn on validation errors beside the field globally Ext.form.Field.prototype.msgTarget = 'side'; var bd = Ext.getBody(); // Define the Grid data and create the Grid var myData = [ ['3m Co',71.72,0.02,0.03,'9/1 12:00am'], ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'], ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am'], ]; var ds = new Ext.data.Store({ reader: new Ext.data.ArrayReader({}, [ {name: 'company'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'} ]) }); ds.loadData(myData); // example of custom renderer function function italic(value){ return '' + value + ''; } // example of custom renderer function function change(val){ if(val > 0){ return '' + val + ''; }else if(val < 0){ return '' + val + ''; } return val; } // example of custom renderer function function pctChange(val){ if(val > 0){ return '' + val + '%'; }else if(val < 0){ return '' + val + '%'; } return val; } // the DefaultColumnModel expects this blob to define columns. It can be extended to provide // custom or reusable ColumnModels var colModel = new Ext.grid.ColumnModel([ {id:'company',header: "Company", width: 160, sortable: true, locked:false, dataIndex: 'company'}, {header: "Price", width: 75, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'}, {header: "Change", width: 75, sortable: true, renderer: change, dataIndex: 'change'}, {header: "% Change", width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'}, {header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'} ]); bd.createChild({tag: 'h2', html: 'Using a Grid with a Form'}); /* * Here is where we create the Form */ var gridForm = new Ext.FormPanel({ id: 'company-form', frame: true, labelAlign: 'left', title: 'Company data', bodyStyle:'padding:5px', width: 750, layout: 'column', // Specifies that the items will now be arranged in columns items: [{ columnWidth: 0.6, layout: 'fit', items: { xtype: 'grid', ds: ds, cm: colModel, sm: new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { switch(row){ case 0: Ext.getCmp('combo').show(); Ext.getCmp('text').hide(); Ext.getCmp('date').hide(); break; case 1: Ext.getCmp('combo').hide(); Ext.getCmp('text').show(); Ext.getCmp('date').hide(); break; case 2: Ext.getCmp('combo').hide(); Ext.getCmp('text').hide(); Ext.getCmp('date').show(); break; } Ext.getCmp("company-form").getForm().loadRecord(rec); } } }), autoExpandColumn: 'company', height: 350, title:'Company Data', border: true, listeners: { render: function(g) { g.getSelectionModel().selectRow(0); }, delay: 10 // Allow rows to be rendered. } } },{ columnWidth: 0.4, xtype: 'fieldset', labelWidth: 90, title:'Company details', defaults: {width: 140}, // Default config options for child items defaultType: 'textfield', autoHeight: true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;', border: false, style: { "margin-left": "10px", // when you add custom margin in IE 6... "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0" // you have to adjust for it somewhere else }, items: [{ xtype:'panel', fieldLabel : '哈哈', isFormField: true, items:[{ id:'combo', value:'ComboBox', xtype:'combo' },{ hidden:true, xtype:'textfield', value:'TextField', id:'text' },{ hidden:true, id:'date', value:'1985-05-01', xtype:'datefield' } ] }] }], renderTo: bd }); // Create Panel view code. Ignore. }); </script> </head> <body> </body> </code></pre> <p></html></p> <p>[/code]</p>本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥30 python代码,帮调试
- ¥15 #MATLAB仿真#车辆换道路径规划
- ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
- ¥15 数据可视化Python
- ¥15 要给毕业设计添加扫码登录的功能!!有偿
- ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
- ¥15 微信公众号自制会员卡没有收款渠道啊
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条