javascript - extjs 4 dinamyc store -


i must update label takes data store. must load store new data ex. each 10 seconds. it's easy - use setinternal() (because taskrunner isn't work o_0)_ , call store.load event. task more specific. have grid contains of 2 columns , takes data store , data custom. means before columns clear store dataindexes there few new records in store custom string data , numeric data... it's may hard explain word, in code looks so:

//---store--- ext.define('app.store.data', {     extend: 'ext.data.store',     autoload: false,     storeid:'data',     model: 'app.model.datamodel',     proxy   : {     type    : 'ajax',     url: 'http://mybackend',     reader: {         type: 'json'     }      },     data:[first = true],     listeners:{         load: function()         {             if(first){             first=false;             myapp.getcontroller('app.controller.controller').storeloadhandler();             setinterval(function (){myapp.getcontroller('app.controller.controller').storeloadhandler();},10000);             }          }     } }); //---controller--- storeloadhandler: function(){     var store = this.getstore('data');     //upload data base store     store.reload();      store.add(             [                 {                     fio: 'somedata',                     //calculate data , write store. dataindexes existsin model                      opercount: parseint(this.getstore('data').first().get('isquick')),                     opersvod: (this.getstore('data').first().get('opersvod')),                     isquick:parseint(this.getstore('data').first().get('isquick')),                     ipk: (this.getstore('data').first().get('ipk')),                     allcount: (this.getstore('data').first().get('allcount')),                     id: 0                 },                 {                     fio:                      ...                     id: 1                 },                 {                     fio:                      ...                     id: 2                 }                    ]         );           //takes labels , use settext, works brilliant     ext.componentquery.query('#toppanel')[0].items.getat(0).items.get('inw').settext(this.storecalc('iw'));     ext.componentquery.query('#toppanel')[0].items.getat(1).items.get('isclose').settext(this.storecalc('isclose'));     ext.componentquery.query('#toppanel')[0].items.getat(2).items.get('denied').settext(this.storecalc('denied'));     ext.componentquery.query('#bottompanel')[0].items.getat(0).items.get('allcount').settext(store.getat(3).get('allcount'));      //use sort     store.sort([     {         property : 'id',         direction: 'asc'     },     {         property : 'fio',         direction: 'ask'//'desc'     }     ]);     store.destroy();     } 

in case when call store.load() method or store.reload() custom records in store lost. if delete operation listing custom data saves , render in grid 2 columns (dataindexes - 'fio' , 'opercount')... problem is?

it looks calling add method no data in store. use callback option of reload method:

store.reload({callback: function() {           store.add(...);   }  }) 

note: not configure reloading timer load method - it's bad understanding


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -