• extjs 3.4 使用XTemplate 改变grid行的显示方式


    为了对grid的行显示变得多样式,使内容的布局更定制。

    效果图:

    代码:

                var data = [
                           { 'id': 1, 'name': '小王', 'sex': '男' },
                           { 'id': 2, 'name': '小李', 'sex': '男' },
                           { 'id': 3, 'name': '小兰', 'sex': '女' }
                 ];
    
                var store = new Ext.data.JsonStore({
                    data: data,
                    fields: ['id', 'name', 'sex']
                });
    
                //创建模板 
                var tplCum = new Ext.XTemplate(
                 '<div><table style="border-bottom-style: groove; border-bottom- thin">',
                 '<tr>                                                              ',
                 '<td style="35px"></td>                                      ',
                 '    <td style="300px">                                      ',
                 '        <table><tr>                                               ',
                 '        <td style="100px">姓名:{name}</td>                 ',
                 '        <td style="100px">性别:{sex}</td>                  ',
                 '        <td >邮箱:</td>                                          ',
                 '        </tr></table>                                             ',
                 '        </td>                                                     ',
                 '    <td style="20px"></td>                                 ',
                 '</tr>                                                             ',
                 '<tr style="height:30px;color:blue;vertical-align: middle;">      ',
                 '    <td >意见:</td>                                              ',
                 '    <td ></td>                                                    ',
                 '    <td >提出时间:{Time}</td>                                    ',
                 '</tr>                                                             ', //每行以逗号隔开
                 '</table></div>                                                    '  //最后一行不用逗号
            );
    
                var AdviceGrid = new Ext.grid.GridPanel({
                          store: store,
                          height:300,
                          region: 'center',
                          autoScroll: true,
                          containerScroll: true,
                          stripeRows: true,
                          frame: true,
                          loadMask: {
                              msg: '数据加载中,请稍等......'
                          },
                          cm: new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),
                                 { header: "编号", dataIndex: "Id", tooltip: "编号", sortable: true, hidden: true,  50 },
                            //模板
                            { text: '描述', xtype: 'templatecolumn', tpl: tplCum,  400 },
                            //按钮
                            { header: "", dataIndex: "c_reply",  50,
                              renderer: function (value, cellmeta) { return "<INPUT type='button' value='回复'>";}
                            },
                            { header: "", dataIndex: "c_agree",  50,
                              renderer: function (value, cellmeta) { return "<INPUT type='button' value='采纳'>"; }
                             }
               
                             ]),
                          tbar: [{
                              pressed: true,
                              enableToggle: true,
                              text: 'add',
                              id: '_btnShowRead',
                              iconCls: 'add',
                              handler: function () {
               
                              }
                          }, '-', {
                              pressed: true,
                              enableToggle: true,
                              text: 'edit',
                              id: '_btnShowAll',
                              iconCls: 'edit',
                              handler: function () {
               
                              }
                          }],
                          bbar: new Ext.PagingToolbar({
                              pageSize: 20,
                              store: store,
                              displayInfo: true
                          })
                    });

    Ps:模板要注意的地方{name}获取store里的值。

    { text: '描述', xtype: 'templatecolumn', tpl: tplCum,  400 },这句是设置模板列
  • 相关阅读:
    最近看代码查到的一些函数,稍作整理(2022.4.1)
    Pytorch的repeat函数
    随机数使用小技巧
    Pytorch的Normal
    OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.报错解决办法
    pytorch tensor索引中的none含义
    scheduled sampling 待完善
    Pytorch的nn.Sequential(*modules)中*的理解
    EOFError: Ran out of input报错解决
    conda安装包报错RemoveError:requests is a dependency of conda and cannot be removed from conda
  • 原文地址:https://www.cnblogs.com/280850911/p/2631858.html
Copyright © 2020-2023  润新知