memory代理方式:
<script type="text/javascript"> //定义数据模型 Ext.define("Person",{ extend : "Ext.data.Model", fields : [ {name:"name", type:"string"}, {name:"age", type:"int"} ] }); //定义Store var personStore = Ext.create("Ext.data.Store",{ model : "Person", proxy : { type : "memory" } }); //往Store添加元素 personStore.add({name:"Ivan",age:"27"}); personStore.add({name:"study",age:"1"}); //遍历Store var msg = []; personStore.each(function(person){ msg.push(person.get("name")+" , "+person.get("age")); }); Ext.onReady(function(){ Ext.Msg.alert("提示",msg.join("<br/>")); }); </script>
?
LocalStorage代理方式:
<script type="text/javascript"> //定义数据模型 Ext.define("Person",{ extend : "Ext.data.Model", fields : [ {name:"name", type:"string"}, {name:"age", type:"int"} ] }); //定义Store var personStore = Ext.create("Ext.data.Store",{ model : "Person", proxy : { type : "localstorage", id : "twitter-Searches"//必需加,否则提示不只一个LocalStorage } }); //往Store添加元素 personStore.add({name:"Ivan",age:"27"}); personStore.add({name:"study",age:"1"}); personStore.sync(); //遍历Store var msg = []; personStore.load(); personStore.each(function(person){ msg.push(person.get("name")+" , "+person.get("age")); }); Ext.onReady(function(){ Ext.Msg.alert("提示",msg.join("<br/>")); }); </script>
?
SessionStorage代理方式:
<script type="text/javascript"> //定义数据模型 Ext.define("Person",{ extend : "Ext.data.Model", fields : [ {name:"name", type:"string"}, {name:"age", type:"int"} ] }); //定义Store var personStore = Ext.create("Ext.data.Store",{ model : "Person", proxy : { type : "sessionstorage", id : "myProxyKey" } }); //往Store添加元素 personStore.add({name:"Ivan",age:"27"}); personStore.add({name:"study",age:"1"}); personStore.sync(); //遍历Store var msg = []; personStore.load(); personStore.each(function(person){ msg.push(person.get("name")+" , "+person.get("age")); }); Ext.onReady(function(){ Ext.Msg.alert("提示",msg.join("<br/>")); }); </script>
?