How to set dynamic url in sencha touch using store? -


i new platform, unable set dyanimic url using category id , token.

what want: have list different items, have different ids same token, token(tokent same 1 user) getting login phase. want value accorading category id server. here model:

ext.define('myapp.model.categorydisplaymodelmenu', {     extend: 'ext.data.model',     config: {         fields: [            /*'cat_id',*/            'category',            'name',         ],          belongsto: "myapp.model.categorydisplaymodel"     } }); 

and another related model is:

ext.define('myapp.model.categorydisplaymodel', {     extend: 'ext.data.model',     requires: ['myapp.model.categorydisplaymodelmenu'],     config: {         fields: [          {name:'data', mapping: 'data'},             {name:'name'},             {name: 'category'},             {name: 'author'},         ],     } }); 

what set in store, not work:

ext.define('myapp.store.categoryvaluestore', {     extend: 'ext.data.store',     alias: 'store.categoryvaluestore',      requires: [         'myapp.model.categorydisplaymodel'     ],      config: {         model: 'myapp.model.categorydisplaymodel',         storeid: 'categoriesvaluestore',      proxy: {         type: 'rest',         url: 'http://horror/myapp/api/word/searched_words/catid/'+ 1+'/'+ sdsillytoken+'/'+650773253e7f157a93c53d47a866204dedc7c363,         nocache: false,                    reader: {             type: 'json',             rootproperty: ''         }  }    } }); 

how set above url, dynamic, cat id , token may differnt.

but works when set these in store

ext.define('myapp.store.architecturedisplaystore',{ extend: 'ext.data.store',  requires:[ 'myapp.view.main' ], config: {     model: 'myapp.model.categorydisplaymodel',     autoload:true,     id:'category',     proxy:     {         type: 'ajax',         url : 'http://horror/myapp/api/word/searched_words/catid/1/sdsillytoken/650773253e7f157a93c53d47a866204dedc7c363', // file containing json data           reader:         {                 rootproperty:''         }  } } }); 

in view , set getting value on list this:

ext.define("myapp.view.architecturedisplaymain", {   extend: 'ext.container',     alias: "widget.architecturewords",     config: {    {               xtype: 'list',        scrollable: true,               itemid: 'demolist',                       itemtpl: [             '<div><tpl for="data"><ul class="catlist">{name} -test- {category}</ul> <ul>{author}</ul></tpl></div>'             ],             store: 'categoriesvaluestore',           }           }           }); 

my category display model:

  ext.define('myapp.model.categorymodelmenu', {     extend: 'ext.data.model',     config: {         fields: [             'cat_id',            'category_name',         ],          belongsto: "myapp.model.categorymodel"     } });  

and

ext.define('myapp.model.categorymodel', {     extend: 'ext.data.model',      requires: ['myapp.model.categorymodelmenu'],      config: {         fields: [          {name:'data', mapping: 'data'},               {name: 'cat_id'},               {name: 'category_name'},         ],     } }); 

edit:

ext.define('myapp.view.category', {     extend: 'ext.list',    alias: "widget.category",      config: {         title: 'stores',         cls: 'category-data',         scrollable: false,         store: 'categorystore',         itemtpl: [          '<div class="categorylistings">',           '<tpl for="data">',           '<span onclick="catoption({cat_id})">{category_name}</span> ',           '</tpl>',           '</div>',          ].join('')     }   //} });  function catoption(id){    console.log("id--"+id); var  tokan= '650773253e7f157a93c53d47a866204dedc7c363';      ext.viewport.remove(ext.viewport.getactiveitem(), true);            ext.viewport.add([               { xtype: 'wordsview' }               ]);    } , others 

in wordsview, display respective words of clicked category.

it ok, when click this, first item of id p1, shows next view.

please tell me, how dynamic data accorading category id , token. please give solution.thank advance.

if understood correctly

let's if have category id , token in localstorage.

you can this

proxy: {    type: 'ajax',    url : 'http://horror/myapp/api/word/searched_words/catid/'+localstorage.catid+'/sdsillytoken/'+localstorage.token,      reader:{        rootproperty:''      }   }  

or

do @alex posted. better way.. like

function catoption(id){   console.log("id--"+id);   var  token= '650773253e7f157a93c53d47a866204dedc7c363';      var url = 'http://horror/myapp/api/word/searched_words/catid/'+id+'/sdsillytoken/'+token;      ext.getstore("categoriesvaluestore").getproxy().seturl(url);      ext.getstore("categoriesvaluestore").load();       ext.viewport.remove(ext.viewport.getactiveitem(), true);        ext.viewport.add({ xtype: 'wordsview' });   } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -