Results 1 to 8 of 8

Thread: Custom Proxy (extends MemoryProxy) How inform the store about new data?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754
    Answers
    7

    Default Answered: Custom Proxy (extends MemoryProxy) How inform the store about new data?

    Hi!

    i have a custom proxy extending the Ext.data.proxy.Memory. It´s difficult to describe, but in my business logic I set the data inside the proxy with

    this.setData(metaData)

    All runs fine, but how can I inform the stores that the Proxy has new data? When I manually do a myStore.load() all data a present. But I want to inform the stores immediately...

    Something like:

    Code:
    this.setData(metaData) // this = the extended Ext.data.proxy.Memory
    this.fireEvent('whatever I must do to force the store automatically to load', this, metaData)

    Any hint?

  2. Something like this:

  3. #2
    Sencha Premium User
    Join Date
    Oct 2012
    Location
    United States
    Posts
    130
    Answers
    11

    Default

    Quote Originally Posted by Dumbledore View Post
    Hi!

    i have a custom proxy extending the Ext.data.proxy.Memory. It´s difficult to describe, but in my business logic I set the data inside the proxy with

    this.setData(metaData)

    All runs fine, but how can I inform the stores that the Proxy has new data? When I manually do a myStore.load() all data a present. But I want to inform the stores immediately...

    Something like:

    Code:
    this.setData(metaData) // this = the extended Ext.data.proxy.Memory
    this.fireEvent('whatever I must do to force the store automatically to load', this, metaData)

    Any hint?
    callback function?
    http://docs.sencha.com/extjs/6.5.3/c...ml#method-load
    Code:
    // taken straight from the docs
    store.load({
        scope: this,
        callback: function(records, operation, success) {
            // the operation object
            // contains all of the details of the load operation
            console.log(records);
        }
    });
    
    // If the callback scope does not need to be set, a function can simply be passed:
    
    store.load(function(records, operation, success) {
        console.log('loaded records');
    });
    wouldn't store load event listener work? store.on('load', function(){
    // dosomething
    }):

    or the datachange event listener?
    -http://docs.sencha.com/extjs/6.5.3/classic/Ext.data.Store.html#event-datachanged

    There's also the possibility of a chained store, but might not work in this instance.
    http://docs.sencha.com/extjs/6.5.3/c...inedStore.html

  4. #3
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754
    Answers
    7

    Default

    you are inside a store with your thoughts

    I am inside a proxy... I need a way to force load the store with a method or event from the proxy!

  5. #4
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Something like this:
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  6. #5
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754
    Answers
    7

    Default

    wrong click... How can i remove "mark as best answer"???

    The custom proxy runs inside electron and receive data via an ipc-Event. All runs fine, but inside the proxy i have no references to the store.
    Currently i set storeId in the proxy definition and to a Ext.Storemanager.lookup to load after receiving the event with the data.

    In my business logic the proxy is the only point to receive the event.

    In your example look at for my comment "look here"...


    PHP Code:
            Ext.create('Ext.grid.Panel', {
                
    title"Drivers",
                
    storestore,
                
    columns: [{
                    
    text'ID',
                    
    dataIndex'id'
                
    }, {
                    
    text'Name',
                    
    dataIndex'name',
                    
    flex1
                
    }, {
                    
    text'Phone Number',
                    
    dataIndex'phoneNumber'
                
    }],
                
    height200,
                
    width400,
                
    renderToExt.getBody()
            });
            
            
    // look here!!!
            // i need to add data from the proxy and have no idea how to inform the store. 
            // the proxy will filled via an specific event.

            
    var proxy =  store.getProxy();
            
    proxy.setData([{
                
    id'3',
                
    name'Me Myself and i',
                
    phoneNumber'555 1234'
            
    }, {
                
    id'4',
                
    name'Joe User',
                
    phoneNumber'666 1234'
            
    }])

            
    // ??? proxy should inform the stores 

  7. #6
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    There are Ext.data.operatin.* classes.
    Looks like you have done something wrong at the beginning (Scheiße gebaut) and now trying to fix it with such a dirty hack.
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  8. #7
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754
    Answers
    7

    Default

    no, it runs fine (keine Scheiße :-) )

    My target is, to run the complete application code as an Web-Application and also inside a electron-app. The only difference between both should be the proxy...

    in german:

    Die ganze Applikation läuft stabil genau richtig mit Stores/Proxies wie es sich gehört. Nur wenn der Code innerhalb von electron läuft kommen die Daten per Event vom NodeJS Main Prozess. Meine Idee war, das ich jeweils nur den Proxy tauschen muss. Das geht jetzt auch, nur muss ich halt die StoreId mitführen.

    Also der electron-main process sendet ans Browserfenster den Event, der Proxy horch und informiert alle Stores.

  9. #8
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    754
    Answers
    7

    Default

    find a way to do the same things from a extended store... don´t know why this runs on my first steps...

    So , it´s solved.

    Thanks!

Similar Threads

  1. Custom proxy not returning data to store
    By petermcg in forum Sencha Touch 2.x: Q&A
    Replies: 4
    Last Post: 30 Apr 2014, 6:15 AM
  2. Custom parsing of fields when loading data into store via proxy
    By azamatoak in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 30 Jan 2013, 11:34 AM
  3. Replies: 4
    Last Post: 25 Jun 2012, 12:44 PM
  4. Replies: 7
    Last Post: 15 Sep 2011, 8:33 PM
  5. Custom Data Store/Proxy
    By [email protected] in forum Ext: Discussion
    Replies: 1
    Last Post: 26 Apr 2011, 12:35 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
  •