1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Question Answered: Loading data into a component without a Store

    Answered: Loading data into a component without a Store


    Hi all!

    I'm a Flex refugee and I'm slowly making my way through ExtJS.
    I'm porting over an ActionScript 3.0 library for doing web-services to an open-source backend I've written, and I want to find out if there's any way to load data into an ExtJS component without a Store? Is this a really stupid question because I don't understand ExtJS yet?

    I'd appreciate any and all help!

  2. OK - I think I've solved the problem.

    I've got a callback on an AJAX request which runs the following code:

    Code:
    success: function(response){
        var list = Ext.getCmp("userlist1");
    
    
        var store = Ext.getStore("Users");
        list.bindStore(store);
    
    
        store.loadData(response);
    }
    I've got a component called userlist1 which I manually bind a Store to using the bindStore function, and then load the response data (which is an array of User model instances) into the Store. This example is using a predefined Store definition, but it's trivial to create a temporary Store on the fly (I'd imagine) and then bind that to a View.

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,663
    Answers
    130
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Default


    Hi tobiu

    That's not quite what I'm looking for; I have the data I want to load into the component already and so I don't need the component to handle its own data retrieval. Is there some event that gets responded to by the Component which causes it to query the associated Store for its data? Perhaps I could fire that event and "fool" the component into thinking that the data is coming from the Store (i hope this makes sense)

    Thanks

  5. #4
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,663
    Answers
    130
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Component
    Code:
    update( String/Object htmlOrData, [Boolean loadScripts], [Function callback] )
    Update the content area of a component.
    
    Parameters
    htmlOrData : String/Object
    If this component has been configured with a template via the tpl config then it will use this argument as data to populate the template. If this component was not configured with a template, the components content area will be updated via Ext.Element update
    loadScripts : Boolean (optional)
    Only legitimate when using the html configuration.
    
    Defaults to: false
    callback : Function (optional)
    Only legitimate when using the html configuration. Callback to execute when scripts have finished loading
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  6. #5
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Default


    Thanks tobiu! That's getting me a little closer, but it's rendering the data as a string of "[object Object]" - not the way the data is rendered when a used with a Store - is there no way to just hook into the process that the Store uses to pass data to the component?

    Thanks for the help!

  7. #6
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,663
    Answers
    130
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    it depends like the comment said. if you have an XTemplate specified for the component, it is basically the same as a store that is bound to a view (which has an XTemplate as well).
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  8. #7
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Default


    Interesting!

    Ok, I'm not very familiar with XTemplates just yet - but I'm trying to load data into a Panel (which I assume would have a default XTemplate applied to it) and it's not working as expected. Do I have to explicitly apply an XTemplate or can I use the default template of the Panel? I tried getting the "tpl" property of the element I'm working with, but it seems to be "undefined".

  9. #8
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Default


    I've found a potential hook in the AbstractView class - there is an "onDataChanged" function which is the callback for the "datachanged" event. This event is fired when data is changed in a Store, and the AbstractView listens for this and accesses the Store's data to render it.

    Is this the right direction to be going in?

  10. #9
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Answers
    1
    Vote Rating
    0
    dannykopping is on a distinguished road

      0  

    Lightbulb


    OK - I think I've solved the problem.

    I've got a callback on an AJAX request which runs the following code:

    Code:
    success: function(response){
        var list = Ext.getCmp("userlist1");
    
    
        var store = Ext.getStore("Users");
        list.bindStore(store);
    
    
        store.loadData(response);
    }
    I've got a component called userlist1 which I manually bind a Store to using the bindStore function, and then load the response data (which is an array of User model instances) into the Store. This example is using a predefined Store definition, but it's trivial to create a temporary Store on the fly (I'd imagine) and then bind that to a View.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar