Results 1 to 2 of 2

Thread: Question on Howto handle Datastores

  1. #1
    Ext User
    Join Date
    Jun 2010
    Location
    Freising - Germany
    Posts
    13

    Default Question on Howto handle Datastores

    Hi,

    I got the following function:

    Code:
    function returnDstore(url,colums,id,root,init){
    	var store = new Ext.data.Store(
    			{
    				url: url,
    				reader: new Ext.data.JsonReader(
    						{
    							root: root,
    							id: id
    						},
    						colums
    				),
    			}
    	);
    	if(init == true){store.load();}return store;
    }
    This makes it easier for me to create a new data Store, as all my data stores are identic.

    Here's the function I'm workin on:
    Code:
    function submitChange(id){
    	var cfg = [
    	           {name: 'status'}
    	          ];
    	var store = returnDstore('<?=$this->link('Workbench','rpc',array('mode'=>'customer','section'=>'updateStatus','id'=>''))?>' + id,cfg,'tid','rows',true);
    	alert(store.getCount());
    }
    Wenn alert fires, the store isn't yet loaded.
    I tried following:
    Code:
    store.on = { 'load': function(){alert(store.getCount);}};
    I don't really get an error message, but the event is never fired.
    I need this, because the script handels an update inside a grid.
    It should update an icon if another icons is clicked (an row operation)
    The part, where this function is called works quite well,
    only the update Part isn't workin.
    I also tried to insert an delay, but that didn't really help.
    I'm not really brand new to javascript.
    A lot of stuff is identic to php.
    Some stuff is new.
    But I don't get the clue that is behind the data stores.
    It would be really great, if someone could help me.
    thx
    Chris

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    1. To avoid confusion you should call the fields 'fields' and not 'colums' (a record has fields - a grid has columns).
    2. Loading is asynchronous. You have to wait for the server to send back the response before you can examine the record count.
    3. You do this by using the load callback or the load event handler, but the syntax is:
    Code:
    store.on('load', function(){alert(store.getCount());});
    4. I would recommend to also add an 'exception' handler to see if your server is returning the data correctly.

Similar Threads

  1. HowTo: ExtJs website accessible iPhone? Howto fixed ScreenSize?
    By Arno.Nyhm in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 27 Feb 2010, 8:19 AM
  2. newbie question - can Form.submit() handle response in XML
    By c_chall in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 15 Oct 2008, 10:48 AM
  3. Editorgrid with different datastores
    By ReSeT in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 22 Feb 2008, 5:04 AM
  4. Question Regarding DataStores
    By mconnors1234 in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 24 Jan 2008, 8:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •