Extjs GRID表格組件使用小結

可編輯表格的插件:

var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 2//雙擊兩次編輯
});

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
        clicksToMoveEditor : 1,
	autoCancel : false
});

點擊保存(按鈕綁定事件略)

function saveChanges(){
	var modifiedRecords = timedTaskStore.getModifiedRecords();
	var modifiedRecNum = modifiedRecords.length;
	if(modifiedRecords==0)return;
	Ext.MessageBox.confirm(
		'變更數據','確定要修改'+modifiedRecNum+'條記錄嗎?',function(btnLabel){
			if(btnLabel=='yes'){
                                grid.stopEditing();
                                grid.getEl().mask('數據傳輸中','x-mask-laoding');                        
                                var recordsToServer = [];
                                Ext.each(modifiedRecords,function(record){
                        	      recordsToServer.push(record.data);
                                });
                                recordsToServer = Ext.encode(recordsToServer);
                                var lastOptions = store.lastOptions;
                                //將當前分頁數據一起發送至服務器
                                Ext.apply(lastOptions.params,{records:recordsToServer});
				//ajax請求省略
				timedTaskStore.commitChanges();
			}
		}
	);
}


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