extjs 保存和修改数据到数据库

 

  1. Ext.define('SMS.store.bastore', {
  2.     extend: 'Ext.data.Store',
  3.     requires: 'SMS.model.beianlistmodel',
  4.     model: 'SMS.model.beianlistmodel',
  5.     pageSize: 20,
  6.     remoteSort: true,
  7.     autoLoad:true,
  8.     proxy: {
  9.         type: 'ajax',
  10.         url: '/server/getbeian.asp',
  11.         reader: {
  12.             root: 'items',
  13.             totalProperty  : 'total'
  14.         },
  15.         simpleSortMode: true
  16.     },
  17.     listeners:{
  18.         update:function(store,record){
  19.             var currPage = store.currentPage;
  20.             //alert(record.get("ID"))
  21.             Ext.Ajax.request({
  22.                 url:'/server/getbeian.asp?action=save',
  23.                 params:{
  24.                     id : record.get("ID"),
  25.                     kehu_name:record.get("kehu_name"),
  26.                     beianhao:record.get("beianhao"),
  27.                     beianpass:record.get("beianpass"),
  28.                     beianemail:record.get("beianemail"),
  29.                     emailpass:record.get("emailpass"),
  30.                     beianzh:record.get("beianzh"),
  31.                     beianzhpa:record.get("beianzhpa"),
  32.                 },
  33.                 success:function(response){
  34.                     store.removeAll();
  35.                     store.load(currPage);
  36.                 }
  37.             });
  38.         },
  39.         remove:function(store,record){
  40.             var currPage = store.currentPage;
  41.             //alert(record.get("ID"))
  42.             Ext.Ajax.request({
  43.                 url:'/server/getbeian.asp?action=del',
  44.                 params:{
  45.                     id : record.get("ID")
  46.                 },
  47.                 success:function(response){
  48.                     store.removeAll();
  49.                     store.load(currPage);
  50.                 }
  51.             });
  52.         }
  53.     },
  54.     sorters: [{
  55.         property: 'ID',
  56.         direction: 'DESC'
  57.     }]
  58. });

通过增加store中listeners: update 和remove事件,通过AJAX来实现

你可能感兴趣的:(职场,update,ExtJs,grid,休闲,edit)