ggt87125 2009-03-21 21:58
浏览 234
已采纳

ext 界面问题

看图,我想根据左边的表格记录,更改红色的部分为 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 = &#39;side&#39;; var bd = Ext.getBody(); // Define the Grid data and create the Grid var myData = [ [&#39;3m Co&#39;,71.72,0.02,0.03,&#39;9/1 12:00am&#39;], [&#39;Alcoa Inc&#39;,29.01,0.42,1.47,&#39;9/1 12:00am&#39;], [&#39;Altria Group Inc&#39;,83.81,0.28,0.34,&#39;9/1 12:00am&#39;], ]; var ds = new Ext.data.Store({ reader: new Ext.data.ArrayReader({}, [ {name: &#39;company&#39;}, {name: &#39;price&#39;, type: &#39;float&#39;}, {name: &#39;change&#39;, type: &#39;float&#39;}, {name: &#39;pctChange&#39;, type: &#39;float&#39;}, {name: &#39;lastChange&#39;, type: &#39;date&#39;, dateFormat: &#39;n/j h:ia&#39;} ]) }); ds.loadData(myData); // example of custom renderer function function italic(value){ return &#39;&#39; + value + &#39;&#39;; } // example of custom renderer function function change(val){ if(val &gt; 0){ return &#39;&#39; + val + &#39;&#39;; }else if(val &lt; 0){ return &#39;&#39; + val + &#39;&#39;; } return val; } // example of custom renderer function function pctChange(val){ if(val &gt; 0){ return &#39;&#39; + val + &#39;%&#39;; }else if(val &lt; 0){ return &#39;&#39; + val + &#39;%&#39;; } 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:&#39;company&#39;,header: &quot;Company&quot;, width: 160, sortable: true, locked:false, dataIndex: &#39;company&#39;}, {header: &quot;Price&quot;, width: 75, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: &#39;price&#39;}, {header: &quot;Change&quot;, width: 75, sortable: true, renderer: change, dataIndex: &#39;change&#39;}, {header: &quot;% Change&quot;, width: 75, sortable: true, renderer: pctChange, dataIndex: &#39;pctChange&#39;}, {header: &quot;Last Updated&quot;, width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer(&#39;m/d/Y&#39;), dataIndex: &#39;lastChange&#39;} ]); bd.createChild({tag: &#39;h2&#39;, html: &#39;Using a Grid with a Form&#39;}); /* * Here is where we create the Form */ var gridForm = new Ext.FormPanel({ id: &#39;company-form&#39;, frame: true, labelAlign: &#39;left&#39;, title: &#39;Company data&#39;, bodyStyle:&#39;padding:5px&#39;, width: 750, layout: &#39;column&#39;, // Specifies that the items will now be arranged in columns items: [{ columnWidth: 0.6, layout: &#39;fit&#39;, items: { xtype: &#39;grid&#39;, ds: ds, cm: colModel, sm: new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { switch(row){ case 0: Ext.getCmp(&#39;combo&#39;).show(); Ext.getCmp(&#39;text&#39;).hide(); Ext.getCmp(&#39;date&#39;).hide(); break; case 1: Ext.getCmp(&#39;combo&#39;).hide(); Ext.getCmp(&#39;text&#39;).show(); Ext.getCmp(&#39;date&#39;).hide(); break; case 2: Ext.getCmp(&#39;combo&#39;).hide(); Ext.getCmp(&#39;text&#39;).hide(); Ext.getCmp(&#39;date&#39;).show(); break; } Ext.getCmp(&quot;company-form&quot;).getForm().loadRecord(rec); } } }), autoExpandColumn: &#39;company&#39;, height: 350, title:&#39;Company Data&#39;, border: true, listeners: { render: function(g) { g.getSelectionModel().selectRow(0); }, delay: 10 // Allow rows to be rendered. } } },{ columnWidth: 0.4, xtype: &#39;fieldset&#39;, labelWidth: 90, title:&#39;Company details&#39;, defaults: {width: 140}, // Default config options for child items defaultType: &#39;textfield&#39;, autoHeight: true, bodyStyle: Ext.isIE ? &#39;padding:0 0 5px 15px;&#39; : &#39;padding:10px 15px;&#39;, border: false, style: { &quot;margin-left&quot;: &quot;10px&quot;, // when you add custom margin in IE 6... &quot;margin-right&quot;: Ext.isIE6 ? (Ext.isStrict ? &quot;-10px&quot; : &quot;-13px&quot;) : &quot;0&quot; // you have to adjust for it somewhere else }, items: [{ xtype:&#39;panel&#39;, fieldLabel : &#39;哈哈&#39;, isFormField: true, items:[{ id:&#39;combo&#39;, value:&#39;ComboBox&#39;, xtype:&#39;combo&#39; },{ hidden:true, xtype:&#39;textfield&#39;, value:&#39;TextField&#39;, id:&#39;text&#39; },{ hidden:true, id:&#39;date&#39;, value:&#39;1985-05-01&#39;, xtype:&#39;datefield&#39; } ] }] }], renderTo: bd }); // Create Panel view code. Ignore. }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; </code></pre> <p></html></p> <p>[/code]</p>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条