Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 无法在本地存储中插入_Extjs_Insert_Sencha Touch_Touch_Local Storage - Fatal编程技术网

Extjs 无法在本地存储中插入

Extjs 无法在本地存储中插入,extjs,insert,sencha-touch,touch,local-storage,Extjs,Insert,Sencha Touch,Touch,Local Storage,我有一个模型: Ext.define('SizoMag.model.SizoBuscetModel', { extend: 'Ext.data.Model', config: { fields: [{name: 'text', type: 'string'}, {name: 'price', type: 'string'}], proxy: { type: 'localstorage', id : 'buscetmodel' } } }); 储存 Ext.define('Sizo

我有一个模型:

Ext.define('SizoMag.model.SizoBuscetModel', {  extend: 'Ext.data.Model',
config: {
fields: [{name: 'text', type: 'string'}, {name: 'price', type: 'string'}],
proxy: {
  type: 'localstorage',
  id  : 'buscetmodel'
 }
}
});
储存

Ext.define('SizoMag.store.SizoBuscetStore', {extend: 'Ext.data.Store',
 config: {
 storeId: 'SizoBuscetStore'
}
});
但是当我尝试向store-get错误中添加条目时 [WARN][Ext.data.Operation#setModel]除非使用元数据定义模型,否则操作需要定义模型。Console.js:35

[WARN][Ext.data.reader.reader#process]为了读取记录数据,读取器需要在其上定义一个模型。Console.js:35

未捕获类型错误:对象不是函数

我补充说

var store=Ext.getStore('SizoBuscetStore');
store.load();store.add({text:'txt',price:'150'});
store.sync();
请帮帮我/
Tnx

试试这个,您需要为商店定义一个模型类型,以便它可以配置其读卡器:

Ext.define('SizoMag.store.SizoBuscetStore', {
    extend: 'Ext.data.Store',
    storeId: 'SizoBuscetStore',
    model: 'SizoBuscetModel'
});

嘿,很简单,试试这个

店内:

   Ext.define('e4b.store.Adult_DOBStore', {
extend: "Ext.data.Store",

config: {
    model: "e4b.model.Adult_DOBModel",
    autoLoad: true, 
    clearOnPageLoad: false,
}

         });
你的模特会是

           Ext.define('e4b.model.Adult_DOBModel', {
extend: 'Ext.data.Model',
config: {

    fields: ['Adult1Date'],


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

       }
}))

现在在你的控球器里

首先获取值

      var A_select1=Ext.getCmp('select1').getValue();

     localStorage.setItem("Adult1_select1",A_select1); //Assign the value to localstore

   var AdultSalutation={
                    // object                               
 'Adult1_select1':A_select1,

                 };

var AdultSalutationstore =Ext.getStore('Adult_AdultSalutationstore');// cal store 

        AdultSalutationstore.add(AdultSalutation);  // add the oject here
      AdultSalutationstore.sync();
   AdultSalutationstore.load();