rowUp : function() {//上移 var records = this.gridPanel.getSelectionModel().getSelections();//得到選中所有行 for(var i in records)//遍歷所選的所有行 { var record = records[i];//每行的數(shù)據(jù)(記錄此數(shù)據(jù)) var index = this.gridPanel.getStore().indexOf(record);//數(shù)據(jù)所在位置 if(0>=index) { return;//不可移動 } var data = record.data; var NewRecord = new Ext.data.Record({ //記錄數(shù)據(jù),remove&和insert方法是記錄數(shù)組(我他媽不知道啥玩意) itemName:data.itemName, //這里面的參數(shù)取gridPanel列表中record的定義 itemIndex:data.itemIndex, maxScore:data.maxScore, minScore:data.minScore, itemType:data.itemType }); this.gridPanel.getStore().removeAt(index);//刪除當(dāng)前所選行數(shù)據(jù) this.gridPanel.getStore().insert(index-1,NewRecord);//將記錄數(shù)據(jù)插入到所刪除數(shù)據(jù)位置的上一位置 this.gridPanel.getView().refresh(); this.gridPanel.getSelectionModel().selectRow(index-1,index-1); } }, rpwDown : function() {//下移 var records = this.gridPanel.getSelectionModel().getSelections();//得到選中所有行 var num = this.gridPanel.getStore().getCount(); for(var i in records)//遍歷所選的所有行 { var record = records[i];//每行的數(shù)據(jù)(記錄此數(shù)據(jù)) var index = this.gridPanel.getStore().indexOf(record);//數(shù)據(jù)所在位置 if(this.gridPanel.getStore().getCount()-1<=index||0>index) { return;//不可移動 } var data = record.data; var NewRecord = new Ext.data.Record({ itemName:data.itemName, itemIndex:data.itemIndex, maxScore:data.maxScore, minScore:data.minScore, itemType:data.itemType }); this.gridPanel.getStore().removeAt(index);//刪除當(dāng)前所選行數(shù)據(jù) this.gridPanel.getStore().insert(index+1,NewRecord);//將記錄數(shù)據(jù)插入到所刪除數(shù)據(jù)位置的下一位置 this.gridPanel.getView().refresh();//刷新(不知道刷的啥) this.gridPanel.getSelectionModel().selectRow(index+1,index+1); } //this.gridPanel.getStore().reload(); },
兩函數(shù)丟事件調(diào)就行了。用起來還行,會有bug(用用就知道,目前不知道咋解決),多選數(shù)據(jù)上下移也行。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com