var menuRec = Ext.create('secnedu.model.menu.menu',values) ; // create model...
this.getMenulist().getStore().insert( 0 ,menuRec ) ; // store add...
this.getMenulist().getStore().sync({
     success : function ( batch ,option ){
console.log( 'success' ) ;     
     } ,
     failure : function (){
console.log( 'failure...' ) ;
this.getMenulist().getStore().rejectChnages() ; // rollback...
     } ,
     scope : this
}) ;
在同步之后如何将 menuId 写入当前行的 menuId,我也不想再重新查询一遍啊...

解决方案 »

  1.   

    write : function ( store, operation, opts ){
    if( operation.action == 'create' ){ //当是添加动作的时候,我们需要进行 (写入服务端id)
    var resModel = Ext.decode(operation.response.responseText) ;
    if( resModel.success == true ){
    Ext.each(operation.records, function(record){
    record.set( 'menuId' ,resModel.data.menuId  ) ;
                    if ( record.dirty ) {
                        record.commit();
                    }
                });
    }
    }
    }
    [align=left]
      

  2.   

    store 需要设置 autoSync:true,会自动请求服务端,或者store.sync()手动同步