Model 使用本地存储sencha touch同步模型

Model 使用本地存储sencha touch同步模型,model,sencha-touch-2,local-storage,sync,Model,Sencha Touch 2,Local Storage,Sync,我需要从服务器获取数据,并将模型与本地存储同步 这是我的密码 model.js Ext.define('bluebutton.model.BlueButton.Loyalty', { extend: 'Ext.data.Model', config: { idProperty: 'loyaltyModel', fields: [ { name: 'fullName' }, { name: 'age

我需要从服务器获取数据,并将模型与本地存储同步

这是我的密码

model.js

Ext.define('bluebutton.model.BlueButton.Loyalty', {
    extend: 'Ext.data.Model',
    config: {
        idProperty: 'loyaltyModel',
        fields: [
             { name: 'fullName' },
             { name: 'age' },

             {  name: 'lastvisited'  },
             {  name: 'consumer_bbID'  },
             {  name: 'merchant_bbID'  },
             {  name: 'sessionId'  },
             {  name: 'deviceId'  },

             {  name: 'updatedPoint'  },
             { name: 'currentPoint' },

             {  name: 'action'  },
             {  name: 'result'  },
             {  name: 'loyaltyMembership_Id'}



        ],

        proxy: {
            type: 'rest',
          url: 'http://192.168.251.131:8080/WebCommon/rest/BBWebService/updateLoyaltyCardPoint',
            reader: 'json',
            actionMethods: {
                create: 'POST',
                read: 'POST',
                update: 'PUT',
                destroy: 'DELETE'
            },


                      noCache: false, // get rid of the '_dc' url parameter

//                    extraParams: {
//                    userid: "test",
//                    // add as many as you need
//                },


//            timeout:300,
//            listeners: {
//                exception: function(proxy, response, operation) {
//                     alert("Connection Problem");
//                       
//                  }
//               },

            reader: {
                type: 'json',

            },

            writer: {
                type: 'json',

            },
        }






    }

});
Store.js

    Ext.define('bluebutton.store.BlueButton.LoginLS', {
    extend: "Ext.data.Store",
    requires: ['bluebutton.model.BlueButton.Login'],
    config: {


         model :'bluebutton.model.BlueButton.Login',

         proxy: {
             type: 'localstorage',
             id: 'loginLS'
         }


    }
});
View.js

 Ext.define('bluebutton.view.Login', {
    extend: 'Ext.form.Panel',
    xtype: 'loginview',
    id: 'loginview',
    requires: [
        'bluebutton.view.Main',
        'Ext.field.Password',
        'bluebutton.store.BlueButton.LoginLS'
    ],

    config: {
        labelWidth: 80,
        frame: true,
        title: 'Please Login',

        items: [

                        {
                            xtype: 'textfield',
                            id: 'bbID',
                            label: 'User ID',

                        },
                        {
                            xtype: 'passwordfield',
                            id: 'bbPassword',
                            label: 'Password',

                        },
                        {
                            xtype: 'button',
                            text: 'Login',
                            id:'btnLogin',
//                            handler: function () {


//                            }
                        },

当我按下“登录”按钮时,如何将我的模型与localstorage同步?请指导我如何解决此问题,这样我可能会误解此问题,但您可以向存储添加一个
storeId
属性,例如“blueButtonStore”,并像这样同步:

Ext.getStore('blueButtonStore').sync();
要使用本地存储中存在的内容加载存储,可以使用

Ext.getStore('blueButtonStore').load();

如果这不是您的问题,请告诉我。

我可能误解了这个问题,但是您可以向存储添加一个
storeId
属性,例如“blueButtonStore”,并像这样同步:

Ext.getStore('blueButtonStore').sync();
要使用本地存储中存在的内容加载存储,可以使用

Ext.getStore('blueButtonStore').load();

如果这与您的问题无关,请告诉我。

创建模型对象时,请在模型对象上设置脏标志:

  var loyalty = Ext.create('bluebutton.model.BlueButton.Loyalty', { ... });
  loyalty.setDirty(true);  // <== missing step!
  var store = Ext.getStore('blueButtonStore');
  store.add(loyalty);
  store.sync();
var-loyalty=Ext.create('bluebutton.model.bluebutton.loyalty',{…});

忠诚。setDirty(真);// 创建模型对象时,在模型对象上设置脏标志:

  var loyalty = Ext.create('bluebutton.model.BlueButton.Loyalty', { ... });
  loyalty.setDirty(true);  // <== missing step!
  var store = Ext.getStore('blueButtonStore');
  store.add(loyalty);
  store.sync();
var-loyalty=Ext.create('bluebutton.model.bluebutton.loyalty',{…});

忠诚。setDirty(真);// 您的商店是
bluebutton.store.bluebutton.LoginLS

请尝试拨打:

Ext.getStore('LoginLS').sync()

适用于我的程序:
我的商店的名称是,例如:
MyApp.Store.settings.settings

要获得这个存储,我只需调用
var settings=Ext.getStore('settings')
现在我可以添加、删除存储中的项目,然后进行同步:
settings.sync()


检查你的商店是否在app.js中定义。

你的商店是
蓝按钮.store.bluebutton.LoginLS

请尝试拨打:

Ext.getStore('LoginLS').sync()

适用于我的程序:
我的商店的名称是,例如:
MyApp.Store.settings.settings

要获得这个存储,我只需调用
var settings=Ext.getStore('settings')
现在我可以添加、删除存储中的项目,然后进行同步:
settings.sync()

检查你的商店是否在app.js中定义。

我尝试Ext.getStore('blueButtonStore').sync();但是获取空值我尝试Ext.getStore('blueButtonStore').sync();但是得到空值