如何EditorGridPanel数据获取

时间:2022-07-11 16:52:22
Ext.onReady(function(){   
       
       
    var cm = new Ext.grid.ColumnModel([{   
        header:"id",   
        dataIndex:"id"  
    },{   
        header:"姓名",   
        dataIndex:"name"  
    //editor:new Ext.form.TextField()   
    },{   
        header:"业务室",   
        dataIndex:"department"  
    //editor:new Ext.form.TextField()   
    },{   
        header:"上午",   
        dataIndex:"morning",   
        editor:new Ext.form.TextField()   
    },{   
        header:"下午",   
        dataIndex:"afternoon",   
        editor: new Ext.form.ComboBox({   
                                    fieldLabel : '性别',   
                                    hiddenName : 'gender',   
                                    store : new Ext.data.SimpleStore({   
                                                fields : ['abbr', 'state'],   
                                                data : [['换休', '换休'],   
                                                        ['事假', '事假'],   
                                                        ['出差', '出差'],   
                                                        ['探亲假','探亲假']]   
                                            }),             
                                    valueField : 'abbr',   
                                    displayField : 'state',   
                                    typeAhead : true,   
                                    mode : 'local',   
                                    triggerAction : 'all',   
                                    emptyText : '请选择性别',   
                                    forceSelection : true,   
                                    selectOnFocus : true,   
                                    editable : false  
                                })   
    },{   
        header:"备注",   
        dataIndex:"note",   
        editor:new Ext.form.TextField()   
    },{   
        header:"日期",   
        dataIndex:"datenote",   
        renderer:Ext.util.Format.dateRenderer('Y年m月d日'),      
        editor:new Ext.form.DateField({format:'Y年m月d日'})   
  
    }]);   
    var fields = ["id","name","department","morning","afternoon","note","datenote",{name:"datenote",type:"date",dateFormat:"Y-n-j"}];   
    var data = [   
        ["1","张三","计算机","正常","正常","无","2008-08-08"],   
        ["2","张三"","计算机","正常","正常","无","2008-08-08"],   
        ["3","张三","计算机","正常","正常","无","2008-08-08"],   
        ["4","张三","计算机","正常","正常","无","2008-08-08"],   
        ["5","张三","计算机","正常","正常","无","2008-08-08"]];   
       
    var store = new Ext.data.SimpleStore({   
        fields:fields,   
        data:data   
       
  
       
    });   
       
  
    var grid = new Ext.grid.EditorGridPanel({   
        title:"考勤",   
        width:720,   
        height:200,   
        cm:cm,   
        store:store,   
                tbar : [{   
                    text : '保存',   
                    tooltip : '保存考勤信息',   
                    iconCls : 'add',   
                    handler:this.onSaveButtonClick,       
                    scope:this     
                       
                       
                }]   
           
    });   
    grid.render(Ext.getBody());   
});  

 初学EXtjs,我想把EditorGridPanel中信息一次存到数据库中怎么做呢?怎么能一次获得表中所有数据?不知道我说清楚没?

3 个解决方案

#1


1、遍历store中的记录,并过滤记录是否被修改过,修改过着保存到数据库中。(当然如果你保存全部数据到数据库不是有特殊目的的话)
2、record中有个属性modified对象表示已修改的key:value键值对。 
3、record中有个hasChanges函数返回修改过的字段的hash表,isModified(field)函数表示该字段是否修改过。这两个函数可以一起使用。

#2


该回复于2009-08-19 16:40:27被版主删除

#3


我现在显示的数据没有在数据库里面,怎么一次把表格中的数据存到数据库呢?
我很弱,说详细点吧 谢谢!

#1


1、遍历store中的记录,并过滤记录是否被修改过,修改过着保存到数据库中。(当然如果你保存全部数据到数据库不是有特殊目的的话)
2、record中有个属性modified对象表示已修改的key:value键值对。 
3、record中有个hasChanges函数返回修改过的字段的hash表,isModified(field)函数表示该字段是否修改过。这两个函数可以一起使用。

#2


该回复于2009-08-19 16:40:27被版主删除

#3


我现在显示的数据没有在数据库里面,怎么一次把表格中的数据存到数据库呢?
我很弱,说详细点吧 谢谢!