function changePlace(store,index,record,indicate){
var keys=store.data.keys;
var items=store.data.items;
var tempKey;
if(indicate=="up"){
if(index>0){
items[index]=items[index-1];
items[index-1]=record;
tempKey=keys[index];
keys[index]=keys[index-1];
keys[index-1]=tempKey;
console.log(record);
console.log(items[index-1]);
}
}
if(indicate=="down"){
if(index<store.getCount()-1){
items[index]=items[index+1];
items[index+1]=record;
tempKey=keys[index];
keys[index]=keys[index+1];
keys[index+1]=tempKey;
}
}
}
这样交换其实是有问题,无法让view得到刷新的效果,可以直接获取model进行交换
,moveRecords:function(indicate,rc){
var me=this;
var offsetIndex;
var rc =rc||me.getCheckedRecords();
if(indicate==="up"){
var index=me.store.indexOf(rc[0]);
offsetIndex=index>0?index-1:index;
}else if(indicate==="down"){
var index=me.store.indexOf(rc[0]);
offsetIndex=index<me.store.getCount()-rc.length?index+1:index;
}
me.store.remove(rc);
me.store.insert(offsetIndex,rc);
}
即通过indexof 查找记录,remove删除记录,然后insert指定位置插入记录,这样可以改变store从而使数据得到自动刷新,至于想要保存刷新前的样式,那可以再加方法实现!