[CLOSED] Rest proxy load and autoload

  1. #1

    [CLOSED] Rest proxy load and autoload

    Hey guys.

    i have a question, why is it that when you put a rest / ajax proxy on a datastore it will call store load before after render..?

    i know that a proxy will call the url specified when the grid is being initialized, but is there no way to control when the read method should be called..?

    suppose i have to call store.load after my grid has put in the ui tree, thous needing the gridID after it has been created since i cant retrive the grid on its ID before it has been created.

    my datastore is set to autoload = false. so in teory the store should not load until my method is being called..

    does anybody know if the flow for a proxy differs for a datastore so you dont have any control over when you call store.load()..?

    Ex.

    this should be call as the first method before my proxy read is called
    
    LIA.Administration.grid.AfterRender = function (grid) {
        grid.getStore().load();
    }
    this is called insted af the method above and as a result the grid variable is null..
    
    LIA.grid.gridGetKeyValuesSingle = function (grid) {
        var tGrid = Ext.getCmp(grid);
        if (tGrid == null) return {};
        if (tGrid.keyValues != undefined) {
            return tGrid.keyValues;
        }
    
        return {};
    };
    Datastore Initialization
    public void BuildStore(bool isPaging)
            {
                var pageSize = 50;
                this.dataStore = new Store()
                {
                    ID = this.ID + "_store",
                    IsPagingStore = isPaging,
                    PageSize = pageSize,
                    AutoDestroy = true,
                    RemoteFilter = true,
                    RemoteSort = true,
                    RemotePaging = true,
                    AutoSync = false,
                    Model =
                    {
                        new Model()
                        {
                            IDProperty = ""
                        }
                    },
                };
                this.Store.Add(dataStore);
            }
    Rest Proxy initialization
    
    public void BuildProxy()
            {
                this.proxy = new AjaxProxy();
                JsonReader reader = new JsonReader()
                {
                    Root = "rows",
                    TotalProperty = "totalCount",
                   // IDProperty = "ID",
                    SuccessProperty = "success",
                    MessageProperty = "message",
                };
                JsonWriter writer = new JsonWriter()
                {
                    WriteAllFields = true,
                    Encode = true,
                    Root = "rows",
                };
                proxy.Reader.Add(reader);
                proxy.Writer.Add(writer);
                this.dataStore.Proxy.Add(proxy);
            }
    "proxy" is the variable for my datastores Rest proxy
    
     public void SetReadMethod(object bClass, String method)
            {
                this.proxy.API.Read = LiaMethod.GetDirectMethod(bClass, method);
                this.proxy.ExtraParams.Add(new Parameter("keys", "LIA.grid.gridGetKeyValuesSingle ('" + this.ID + "')", ParameterMode.Raw));
    
            }
    Best regard

    Akpenob..
    Last edited by Daniil; Nov 06, 2012 at 5:51 AM. Reason: [CLOSED]
  2. #2
    Hi @Akpenob,

    Quote Originally Posted by Akpenob View Post
    my datastore is set to autoload = false. so in teory the store should not load until my method is being called..
    I can't see where you set up AutoLoad to false for the Store in your sample code.

    The Store should not be autoloaded with this setting.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Akpenob,

    I can't see where you set up AutoLoad to false for the Store in your sample code.

    The Store should not be autoloaded with this setting.
    Hi Danill..

    Thanks for the quick ansvare..

    The code for the datastore being set to autoload false is here.

    
    public void SetupGrid()
            {
                SelectionModel.Add(new RowSelectionModel()
                {
                    ID = this.ID + "_rowselector",
                    Mode = SelectionMode.Single
                }
                );
                EnableColumnHide = true;
                ColumnModel.Sortable = true;
                this.Layout = "Fit";
    
                dataStore.AutoLoad = false;
                
                IsDynamic = true;
                this.Listeners.AfterRender.Handler = "LIA.Administration.grid.AfterRender(#{" + this.ID + "})";
                
            }
    Code for inistializing the grid...

    
    public LiaBaseGrid(String id, bool addPaging,ILiaBase liaBase)
             {
                 LiaBase = liaBase;
                 ID = id;
                 dataStore = new Ext.Net.Store();
                 proxy = new RestProxy();
                 if (addPaging)
                 {
                     BuildStore(addPaging);
                     BuildPaging();
                 }
                 else
                 {
                     BuildStore(false);
                 }
                 BuildProxy();
                 SetupGrid();
    
             }
    I think this is due to my own part since i set it as an extra parameter and since i do that, the method is called appon creating the extra parameter and not during the load call....

    I might be wrong on this, but this would be my own best guess, can you verify that the method is called during the creation of the parameter insted as part of the load call..?

    Anyway i found a different way to handle it, and now i get the parameters i need appon creating the grid.. :-) again thanks for quick respond.

    pls close this :-)

    Best Regards

    Akpenob
  4. #4
    Quote Originally Posted by Akpenob View Post
    I might be wrong on this, but this would be my own best guess, can you verify that the method is called during the creation of the parameter insted as part of the load call..?
    Not sure that I understand the question well, but setting up a Store's AutoLoad property when this Store is already rendered doesn't make sense.
  5. #5
    Quote Originally Posted by Daniil View Post
    Not sure that I understand the question well, but setting up a Store's AutoLoad property when this Store is already rendered doesn't make sense.
    The nature of this question was, when my grid was created, the proxy.api.read "seemed" to being fired.. but in reality it was the call for the extra parameter that got called to early and thous the grid variable ended up being null insted of being the grid..

    The reason for setting the datastore to autoload = false, was so i could insure that grid exsited in the UI tree of the page insted of getting null when the load method got called.

    But what i found out was that, my method got called, but not due to the load call or proxy.api.read, but because of adding extra parameter to proxy.api.read.

    It seemed that when i added the extra parameter, my method would immediately be called to retrive the data for the extra paramter insted of wating for the read call..

    This is the reason why i though that load was called before the after render event since i could see i the debug, that the method for extra paramter was fired before my after render method.. :-)

    I hope this clear it a bit.

    Again thanks for at great support.

    Best regard

    Akpenob
  6. #6
    Thank you for the details.

    Quote Originally Posted by Akpenob View Post
    It seemed that when i added the extra parameter, my method would immediately be called to retrive the data for the extra paramter insted of wating for the read call..
    Well, yes, a Proxy's Parameters collection is populated on rendering stage. You could use a Store's Parameters property. It will be populated just before a load request.

    Hope this helps.
  7. #7
    Quote Originally Posted by Daniil View Post
    Thank you for the details.

    Well, yes, a Proxy's Parameters collection is populated on rendering stage. You could use a Store's Parameters property. It will be populated just before a load request.

    Hope this helps.
    Indeed it does, thanks the quick replay :-)

    Best Regards

    Akpenob

Similar Threads

  1. [CLOSED] Load data to store of combobox by proxy
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 08, 2012, 8:29 AM
  2. Replies: 13
    Last Post: Sep 07, 2012, 6:23 PM
  3. [CLOSED] Avoid Store Autoload on HTTP Proxy
    By dev in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 12, 2011, 2:39 PM
  4. autoload datastore records from http proxy
    By hnafar in forum 1.x Help
    Replies: 1
    Last Post: Feb 11, 2010, 7:50 AM
  5. How to load PDF document in AutoLoad?
    By dbassett74 in forum 1.x Help
    Replies: 1
    Last Post: May 14, 2009, 5:30 PM

Tags for this Thread

Posting Permissions