分組表格和表格響應表單實例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">   
<html>   
    <head>   
        <title>loadrecord.html</title>   
        <link rel="stylesheet" type="text/css" href="./ext-3.3.1/resources/css/ext-all.css" />   
        <script type="text/javascript" src="./ext-3.3.1/adapter/ext/ext-base.js"></script>   
        <script type="text/javascript" src="./ext-3.3.1/ext-all.js"></script>   
        <script type="text/javascript" src="loadrecord.js"></script>   
    </head>   
    <body>   
    </body>   
</html>

Ext.onReady(function(){   
    Ext.QuickTips.init();   
    Ext.form.Field.prototype.msgTarget="qtip";   
    var data = [   
                ["1","男",new Date(1979,09,06),"tom",21,"[email protected]"],   
                ["2","女",new Date(1980,08,07),"tony",46,"[email protected]"],   
                ["3","男",new Date(1990,07,08),"Jet Li",31,"[email protected]"],   
                ["4","女",new Date(1910,06,09),"washington",29,"[email protected]"]   
    ];   
    var fields = ['id','sex','brithday','name','age','eamil'];   
    var cm = new Ext.grid.ColumnModel([   
        { header: "ID", width: 60, sortable: true,dataIndex :'id'
        },   
        { header: "性別", width: 70, sortable: true,dataIndex :'sex'
        },   
        { header: "生日", width: 130, sortable: true,dataIndex :'brithday',   
            editor:new Ext.form.DateField()   
        },   
        { header: "姓名", width: 100, sortable: true,dataIndex :'name'},   
        { header: "年齡", width: 100, sortable: true,dataIndex :'age'
        },   
        { header: "Email", width: 120, sortable: true,dataIndex :'eamil'
        }   
    ]);   
    var store = new Ext.data.GroupingStore({   
        data :data,   
        reader : new Ext.data.ArrayReader({id:"id"},fields)   
    });   
    var gridForm = new Ext.FormPanel({   
        id: 'user_info',   
        applyTo:Ext.getBody(),   
        frame: true,   
        autoHeight:true,   
        labelAlign: 'left',   
        title: '員工信息表',   
        bodyStyle:'padding:5px',   
        width: 600,   
        items:[new Ext.grid.GridPanel({   
            title:"人員信息列表",   
                    width:600,   
                    autoHeight:true,   
                    fram:true,   
                    cm:cm,   
                    store:store,   
                    sm:new Ext.grid.RowSelectionModel({   
                        singleSelect: true,   
                        listeners: {   
                rowselect: function(sm, row, rec) {   
                    Ext.getCmp("user_info").getForm().loadRecord(rec);   
                }   
            }   
                    }),   
                    view:new Ext.grid.GroupingView({   
                        hideGroupedColumn : true,   
                        showGroupsText :"分組顯示",   
                        groupByText:"使用當前字段排序",   
                        forceFit :true,   
                        columnsText :"隱藏/顯示字段",   
                        sortAscText:"升序排列",   
                        sortDescText:"降序排列" 
                    })   
        }),{   
                xtype: 'fieldset',   
            labelWidth: 150,   
            title:'加載grid信息內容',   
            defaultType: 'textfield',   
            autoHeight: true,   
            items:[{   
                fieldLabel: 'ID',   
                name :'id',   
                anchor : '55%' 
            },{   
                fieldLabel: '性別',   
                name :'sex',   
                anchor : '55%' 
            },{   
                fieldLabel: '生日',   
                name :'brithday',   
                anchor : '55%' 
            },{   
                fieldLabel: '年齡',   
                name :'age',   
                anchor : '55%' 
            },{   
                fieldLabel: '郵箱',   
                name :'eamil',   
                anchor : '55%' 
            }]   
        }]   
    });   
});

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章