extjs 裡執行多行選中,和單行選中的操作

朱智文發表於2015-11-04

//獲取選中多行資料

var rows = grid.getSelectionModel().getSelections();// 返回值為Record 陣列

//獲取選中單行資料

var _rd = grid.selModel.getSelected();//返回值為 一個record結果集

 

//獲取所有編輯過的資料

var modifieds = grid.getStore().getModifiedRecords();

 

 

 

頁面使用過程中完整程式碼:(僅供參考)

var modifieds = grid.getStore().getModifiedRecords();
  var changerows = [];
  for(vari=0;i<modifieds.length;i++){
   changerows.push(modifieds[i].data);
  }
  if(changerows.length==0){
   showInfoMsg("資料無修改,不做儲存處理。");
   return;
  }
  Ext.Ajax.request({
   url:"*.jsp",
   params:{datas:Ext.util.JSON.encode(changerows)},
   success:function(){showInfoMsg("資料儲存成功!");_store.commitChanges();},
   failure:function(){showErrorMsg("儲存資料時發生錯誤,儲存失敗!");}
  });

 

//後臺解析params

   String datas =request.getParameter("datas");
   JSONArray jSONObject = JSONArray.fromObject(datas);
   Object[] os =jSONObject.toArray();
   for(inti=0;i<os.length;i++){
     JSONObjectjsonObj = JSONObject.fromObject(os[i]);
     鍵值 = jsonObj.getString("鍵名");
   }

 

實現多行刪除 和編輯  ok!~~

相關文章