PropertyGrid代码示例(Ext1.x)

来源:百度文库 编辑:神马文学网 时间:2024/04/29 07:03:33
Extjs Documentation Center中竟然没有Ext.grid.PropertyGrid的APIDOC和Examples(估计要收费才有完整的文档, 有点恶心).例子代码如下: Ext.namespace('Ext.propsgriddata');
   
       //客户类型
        Ext.propsgriddata.custtype = [
        ['1', '个人'],
        ['0', '机构']
    ];var Ed = Ext.grid.GridEditor;
   
        var propsGrid = new Ext.grid.PropertyGrid('props-grid', ...{
        nameText: 'new query',
        enableHdMenu: false,
        viewConfig : ...{
            forceFit:true,
            scrollOffset:2 // the grid will never have scrollbars
        }
    });    propsGrid.setSource(...{
        "(名称)": "新查询",
        "客户类型": "个人",
        "对帐单寄送": true,
        "有效地址": false,
        "有效手机号": false,
        "有效Email": false,
        "合并持有金额":0,
           "截止持有日期":new Date()
    });    //实现单元格的自定义editor
    propsGrid.customEditors = ...{
        '客户类型' : new Ed(new Ext.form.ComboBox(...{
            typeAhead: true,
            triggerAction: 'all',
            store: new Ext.data.SimpleStore(...{
                fields: ['cust_type', 'cust_type_name'],
                data : Ext.propsgriddata.custtype
            }),
            displayField:'cust_type_name',
            forceSelection:true,
            name:'cust_type',
            valueField:'cust_type',
            mode:'local'
        }))
    };    //改变grid中日期值的格式为'yyyy/mm/dd'
    propsGrid.getColumnModel().dateFormat = 'Y/m/d';    //改变DateField中日期值的格式为'yyyy/mm/dd'
    var f = Ext.form;
    propsGrid.getColumnModel().editors['date']= new Ext.grid.GridEditor(new f.DateField(...{format:'Y/m/d',selectOnFocus:true}));
   
    propsGrid.render();
对于customerEditor,还需要定义propsGrid.colModel.renderCellDelegate,以便在PropertyGrid的value列显示文本(个人/机构),另外,对于默认值是date类型的属性,例如上面的“截止持有日期”,PropertyGrid会自动配置一个DateField作为Editor,但是这个DateField Editor有一个问题,如果删除value值后,点按其它位置,然后再次点按“截止持有日期”的value单元,DateField Editor不会出现,变成了普通的文本框了。解决的方法是,将默认值设为空'',然后手工为属性设置一个DateField Editor 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xujiaqiang/archive/2007/07/09/1683768.aspx