[CLOSED] Remote paging GridPanel

  1. #1

    [CLOSED] Remote paging GridPanel



    Hi

    I have List<> with 350 rows. I am trying to implement remote paging and want to make sure that I am using correct steps.
    Also I am creating store and gridpanel all in code-behind

    I did not include all code in CreateGrid as it is quite large. My question is are these the steps to perform Remote Paging. My Code is working right now expect that CreateGrid is called twice when the form first starts. but My main concern is to get the pattern right for optimun load time.

    1. Create Store
    2. Set store.Autoload = True;
    3. Set store.RemoteSort = true;
    4. Set store.RemotePaging = true;
    5. Set AutoLoadParams for start and limit
    5a. Is it necessary to set store.BaseParams
    6. Is it necessary to set store.Proxy.Add(new DataSourceProxy());
    7. i think this is only needed if using HttpProxy
    //((Coolite.Ext.Web.JsonReader)store.Reader[0]).TotalProperty = "TotalRecords";
    //((Coolite.Ext.Web.JsonReader)store.Reader[0]).Root = "Data";

    Right now with step 1 through 6, my page loads - calls CreateGrid() twice then fires GridRefresh event where the first 15 rows are returned. it stills takes about 8 seconds to render the grid - even though it is only 15 rows and 6 fields in store.
    When I click on Page 2, CreateGrid() is called once and then Gridrefresh is called.

    for my problem with creation of controls twice the first time, is it better to turn Autoload=false and do some kind of store.load(). what would be the best way to do this via code-behind.

    thanks for your help
    idriss

    private Store store = null;
    protected void Page_Load(object sender, EventArgs e)
    {
         CreateGrid();   // this is being called twice the first time the form loads
        // which created the grid and store code-behind
    }
    
    private void CreateGrid()
    {
     GridPanel grid = null;
             // used to set pager size limit in pager section and also in store.AutoLoadParams
                int _limit = 15;
    
                store = new Store { ID = "store1" };
    
    
                ph1.Controls.Add(store);
    
    
                store.RefreshAfterSaving = RefreshAfterSavingMode.Always;
                store.AutoLoad = true;
                store.RemoteSort = true;
                store.RemotePaging = true;
                store.AutoLoadParams.Add(new Parameter { Name="start", Value="0", Mode= ParameterMode.Raw});
                store.AutoLoadParams.Add(new Parameter { Name = "limit", Value = _limit.ToString(), Mode = ParameterMode.Raw });
                store.BaseParams.Add(new Parameter { Name = "start", Value = "0" });
                store.BaseParams.Add(new Parameter { Name = "limit", Value = _limit.ToString() });
                //store.BaseParams.Add(new Parameter { Name = "startRemote", Value = "={0}" });
                //store.BaseParams.Add(new Parameter { Name = "limitRemote", Value = "={25}" });
                store.Proxy.Add(new DataSourceProxy());
    
    
                store.Listeners.LoadException.Handler = "var e = e || {message: response.responseText}; alert('Load failed: ' + e.message);";
                store.Listeners.CommitFailed.Handler = "Ext.Msg.alert('Commit failed', 'Reason: ' + msg)";
                store.Listeners.SaveException.Handler = "Ext.Msg.alert('Save failed', e.message || e)";
                store.Listeners.CommitDone.Handler = "Ext.Msg.alert('Commit', 'Your data has been saved');";
    
    
                store.Reader.Add(new JsonReader());
    
    
                ((Coolite.Ext.Web.JsonReader)store.Reader[0]).ReaderID = "reader1";
    
    
                // i think this is only needed if using HttpProxy
                //((Coolite.Ext.Web.JsonReader)store.Reader[0]).TotalProperty = "TotalRecords";
                //((Coolite.Ext.Web.JsonReader)store.Reader[0]).Root = "Data";
    
    //=================
    // More code here to build grid
    //==================
     store.RefreshData += new Store.AjaxRefreshDataEventHandler(GridRefresh);
            //store.BeforeStoreChanged += new Store.BeforeStoreChangedEventHandler(GridBeforeChanged);
            store.BeforeRecordDeleted += new Store.BeforeRecordDeletedEventHandler(store_BeforeRecordDeleted);
    
    
            Coolite.Ext.Web.RowSelectionModel sm = new RowSelectionModel { ID = "rowSelection", SingleSelect = true };
            
     grid.SelectionModel.Add(sm);
    }
    
    public Paging<IFG.Data.NavRisk.Vehicles> ColPaging(int start, int limit, string sort, string dir, string filter)
        {
            List<IFG.Data.NavRisk.Vehicles> result = IFG.Data.RQController.GetVehicles(PolicyID);
    
    
            //if (!string.IsNullOrEmpty(filter) &amp;&amp; filter != "*")
            //{
            //    contacts.RemoveAll(plant => !plant.FirstName.ToLower().StartsWith(filter.ToLower()));
            //}
    
    
            if (!string.IsNullOrEmpty(sort))
            {
                result.Sort(delegate(IFG.Data.NavRisk.Vehicles x, IFG.Data.NavRisk.Vehicles y)
                {
                    object a;
                    object b;
    
    
                    int direction = dir == "DESC" ? -1 : 1;
    
    
                    a = x.GetType().GetProperty(sort).GetValue(x, null);
                    b = y.GetType().GetProperty(sort).GetValue(y, null);
    
    
                    return System.Collections.CaseInsensitiveComparer.Default.Compare(a, b) * direction;
                });
            }
    
    
            if ((start + limit) > result.Count)
            {
                limit = result.Count - start;
            }
    
    
            List<IFG.Data.NavRisk.Vehicles> range = (start < 0 || limit < 0) ? result : result.GetRange(start, limit);
    
    
            return new Paging<IFG.Data.NavRisk.Vehicles>(range, result.Count);
        }
    
    protected void GridRefresh(object sender, StoreRefreshDataEventArgs e)
        {
    
     Paging<IFG.Data.NavRisk.Vehicles> res = ColPaging(e.Start, e.Limit, e.Sort, e.Dir.ToString(), "");
    
    
            Msg.Text += "GridRefresh BEGIN-2 Called at " + DateTime.Now;
            e.TotalCount = res.TotalRecords;
            store.DataSource = res.Data; // result.ToList();
            store.DataBind();
    }
    
     protected void RowSelect_Event(object sender, AjaxEventArgs e)
        {
    }
  2. #2

    RE: [CLOSED] Remote paging GridPanel

    one more thing, I am using 0.8.2 as the coolite version.
    thanks
  3. #3

    RE: [CLOSED] Remote paging GridPanel

    Hi,

    1. BaseParams is not required if you use AutoLoad and have defined AutoLoadParams. Otherwise define BaseParams or pass required params when you trigger loading
    Store1.reload({params:{start:0, limit:10}});

    2. Any proxy (DataSourceProxy or HttpProxy) is required for remote paging


    3. Twice calling. First calling: initial page rendering. Second calling: proxy perfoms request to retrieve data. You use DataSourceProxy therefore the page is requested (page is recreating). Use HttpProxy and HttpHandler(WebService) to avoid that


    4. it stills takes about 8 seconds to render the grid - even though it is only 15 rows and 6 fields in store.
    Is it SQL request issue?
  4. #4

    RE: [CLOSED] Remote paging GridPanel

    thanks vlad

    i will try httpProxy. If I am using HttpProxy, then do I need to specify these 2 properties

        //((Coolite.Ext.Web.JsonReader)store.Reader[0]).TotalProperty = "TotalRecords";
        //((Coolite.Ext.Web.JsonReader)store.Reader[0]).Root = "Data";
    Also about point #4


    4. it stills takes about 8 seconds to render the grid - even though it is only 15 rows and 6 fields in store.
    Is it SQL request issue?
    No sql comes back in less than 1 sec - the time there is right after the last statement on Store_refresh Event - After it exits the event, it takes like 8 seconds to render grid on IE8.

    idriss
  5. #5

    RE: [CLOSED] Remote paging GridPanel

    Hi,

    1. Yes, with HttpProxy you have to use those properties


    2. Can you create simple example which reproduces that time issue? For example, generates temp data in the code instead DB request
  6. #6

    RE: [CLOSED] Remote paging GridPanel

    This because you are using
    AutoLoad=True
    , the first hit is when the pages i requested, the second happens after the grid is being rendered and its stores is trying to get the data because automatically because AutoLoad is set to true.

    If you are filling data in the store within your createGrid method then set the autoLoad to false, and instead of using autoload params assign their values(start, pagesize) directly to the datapager itself.
  7. #7

    RE: [CLOSED] Remote paging GridPanel



    Thanks for the info.

    and Vlad, I will put sample together and see if I get same results.

    thanks
    idriss

Similar Threads

  1. GridPanel Remote Paging with SqlDatasource
    By Aod47 in forum 1.x Help
    Replies: 1
    Last Post: Oct 25, 2013, 6:00 AM
  2. Replies: 6
    Last Post: Nov 03, 2012, 10:48 PM
  3. GridPanel Remote Paging Problem
    By zhangjiagege in forum 1.x Help
    Replies: 6
    Last Post: Nov 22, 2011, 8:17 AM
  4. [CLOSED] GridPanel remote paging issue
    By jskibo in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Jan 31, 2011, 8:37 AM
  5. [CLOSED] Export Data To Excel in Remote Paging GridPanel
    By pdcase in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 11, 2010, 8:49 PM

Posting Permissions