zoukankan      html  css  js  c++  java
  • EXT 列头合并的例子

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Editor Grid Example</title>

    <link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/resources/css/ext-all.css" />

        <!-- GC -->
      <!-- LIBS -->
      <script type="text/javascript" src="http://www.cnblogs.com/adapter/ext/ext-base.js"></script>
      <!-- ENDLIBS -->

        <script type="text/javascript" src="http://www.cnblogs.com/ext-all.js"></script>
        <script type="text/javascript" src="http://www.cnblogs.com/source/locale/ext-lang-zh_CN.js"></script>
     
    </head>
    <body>
     
     <script language="JavaScript">
     <!--
    MyGridView=Ext.extend(Ext.grid.GridView,{
      renderHeaders : function(){
          var cm = this.cm, ts = this.templates;
          var ct = ts.hcell,ct2=ts.mhcell;
         
          var cb = [], sb = [], p = {},mcb=[];   
          for(var i = 0, len = cm.getColumnCount(); i < len; i++){
              p.id = cm.getColumnId(i);
              p.value = cm.getColumnHeader(i) || "";
              p.style = this.getColumnStyle(i, true);
              if(cm.config[i].align == 'right'){
                  p.istyle = 'padding-right:16px';
              }
              cb[cb.length] = ct.apply(p);
              if(cm.config[i].mtext)mcb[mcb.length]=ct2.apply({value:cm.config[i].mtext,mcols:cm.config[i].mcol});
          }
          var s=ts.header.apply({cells: cb.join(""), tstyle:''+this.getTotalWidth()+';',mergecells:mcb.join("")});
          return s;
      }
    });
    viewConfig={
             templates:{              
                 header:new Ext.Template(
                      '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
                      '<thead><tr class="x-grid3-hd-row">{mergecells}</tr>' +
                      '<tr class="x-grid3-hd-row">{cells}</tr></thead>',
                      "</table>"
                      ),
              mhcell: new Ext.Template(
                      '<td class="x-grid-cell" colspan="{mcols}"><div align="center"><b>{value}</b></div>',
                      "</td>"
                      )   
             }
         };
    Ext.onReady(function(){   
     var data=[{id:1,
                 name:'小王',
                 email:'xiaowang@easyjf.com',
                 sex:'男',
                 bornDate:'1991-4-4'},
               {id:1,
                 name:'小李',
                 email:'xiaoli@easyjf.com',
                 sex:'男',
                 bornDate:'1992-5-6'},
              {id:1,
                 name:'小兰',
                 email:'xiaoxiao@easyjf.com',
                 sex:'女',
                 bornDate:'1993-3-7'}           
             ];
     var store=new  Ext.data.JsonStore({
         data:data,
         fields:["id","name","sex","email",{name:"bornDate",type:"date",dateFormat:"Y-n-j"}]
             });   
         var colM=new Ext.grid.ColumnModel([{
                     header:"姓名",
                     mtext:"基本信息",
                     mcol:2,
                     dataIndex:"name",
                     sortable:true,
                     editor:new Ext.form.TextField()},               
                  {header:"性别",
                   dataIndex:"sex",
                   editor:new Ext.form.ComboBox({transform:"sexList",
                                                   triggerAction: 'all',
                                                   lazyRender:true})
                   },
                  {header:"出生日期",
                   dataIndex:"bornDate",
                    mtext:"其它信息",
                     mcol:2,
                   120,
                   renderer:Ext.util.Format.dateRenderer('Y年m月d日'),
                   editor:new Ext.form.DateField({format:'Y年m月d日'})},
                  {header:"电子邮件",
                   dataIndex:"email",
                   sortable:true,
                   editor:new Ext.form.TextField()}
                  ]);
     var grid = new Ext.grid.EditorGridPanel({
         renderTo:"hello",
         title:"学生基本信息管理",
         height:200,
         600,   
         cm:colM,
         store:store,
         view:new MyGridView(viewConfig),
         autoExpandColumn:3
     });
    });

     

     //-->
     </script>

     
    <div id="box"></div>
    <div id="hello"></div>
    <select name="sexList" id="sexList" style="display: none;">
         <option>男</option>
         <option>女</option>
    </select>

    </body>
    </html>

  • 相关阅读:
    Search Insert Position
    lintcode: 最长连续序列
    lintcode:颜色分类
    lintcode: 堆化
    lintcode: 旋转图像
    lintcode: 寻找旋转排序数组中的最小值
    lintcode: 跳跃游戏 II
    lintcode:最小差
    华为:数独填充
    华为:字符集合
  • 原文地址:https://www.cnblogs.com/winner/p/1392277.html
Copyright © 2011-2022 走看看