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中信息一次存到数据库中怎么做呢?怎么能一次获得表中所有数据?不知道我说清楚没?
哥们,不需要一次获得,你每次操作完以后会有个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){}
});
}
}
}