meihua212 2009-03-11 16:33
浏览 314
已采纳

如何EditorGridPanel数据获取

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中信息一次存到数据库中怎么做呢?怎么能一次获得表中所有数据?不知道我说清楚没?

  • 写回答

1条回答 默认 最新

  • 马勒格彼得 2009-03-11 17:20
    关注

    哥们,不需要一次获得,你每次操作完以后会有个COMMIT提交到后台的,一次提交是不现实的,不过你实在想弄的话,我可以跟你说,你可以这样,写个方法逐个添加
    function uploadAll(){
    grid.stopEditing();// 停止编辑
    if(store!=null){
    for(i=0;i<store.getCount();i++){
    var record=store.getAt(i);
    Ext.Ajax.request({
    url:'保存数据的方法',params:{参数1:record.get('值1'),参数n:record.get('值n')},method:'post',
    success:function(response,options){//提交成功},
    failure:function(response,options){}

    });
    }
    }
    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能