[CLOSED] Local Paging for Remote Data Issue

Page 1 of 3 123 LastLast
  1. #1

    [CLOSED] Local Paging for Remote Data Issue

    Hi Guys,

    I am using "Local Paging for Remote Data" as shown in the example (https://examples1.ext.net/#/GridPane...h_Remote_Data/)
    I am able to get it working with the slider and local paging is also working fine.
    Now I have couple of issues:
    1. First, If I need to include the filter using combo box and it filters the data into 50%. When I try to bind the data again, I am unable to clear the grid content. It is having the old data cached. Can you please resolve this for me ?
    2. (Optional) Is there a way to replace slider control with any other control which is user-friendly ? Lets say, If I have 200K records, then the slider will not be more user-friendly. Please suggest me on this as well.

    Thanks in Advance.

    Regards,
    Dan
    Last edited by Daniil; Apr 12, 2011 at 8:47 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by dnguyen View Post
    1. First, If I need to include the filter using combo box and it filters the data into 50%. When I try to bind the data again, I am unable to clear the grid content. It is having the old data cached. Can you please resolve this for me ?
    Hi,

    Not sure what you mean. Could you provide a sample?

    Quote Originally Posted by dnguyen View Post
    2. (Optional) Is there a way to replace slider control with any other control which is user-friendly ? Lets say, If I have 200K records, then the slider will not be more user-friendly. Please suggest me on this as well.
    I can suggest to use SpinnerField.
    https://examples1.ext.net/#/Form/SpinnerField/Overview/
  3. #3
    <ext:ComboBox ID="cbTest" runat="server"
                        DisplayField="Display" ValueField="Data"
                        TypeAhead="true"
                        Mode="Local" 
                        Editable="true"
                        ForceSelection="true"
                        AllowBlank="true"
                        TriggerAction="All" 
                        Width="200">
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                        <Reader>
                            <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="Data" Mapping="Data"/>
                                <ext:RecordField Name="Display" Mapping="Display"/>
                            </Fields>
                            </ext:ArrayReader>
                        </Reader>
                        </ext:Store>
                    </Store>
                    <DirectEvents>
                        <Select OnEvent="cbTest_Change">
                            <EventMask ShowMask="true" />
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>
    <ext:GridPanel
                ID="GridPanel1" 
                runat="server"
                Collapsible="false"
                AutoWidth="true"
                Height="425"
                Frame="true">
                <Store>
                    <ext:Store runat="server" ID="GridPanel1" 
                            RemotePaging="false"
                            OnRefreshData="Store_Refresh">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <BaseParams>
                            <ext:Parameter Name="startRemote" Value="#{PagingSlider}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="limitRemote" Value="#{PagingSlider}.increment" Mode="Raw" />
                            <ext:Parameter Name="start" Value="0" Mode="Raw" />
                            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
                        </BaseParams>
                    </ext:Store>
                </Store>.......<TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Slider ID="PagingSlider" runat="server" FieldLabel="# Records"
                                MinValue="0"
                                Width="400">
                                <Plugins>
                                    <ext:SliderTip runat="server" />
                                </Plugins>
                                <Listeners>
                                    <Change Handler="#{RangeText}.setText((newValue+1) + '-' + (newValue + #{PagingSlider}.increment) + ' of ' + #{PagingSlider}.maxValue)" />
                                    <ChangeComplete Handler="remoteLoad(#{GridPanel1});" />
                                </Listeners>
                            </ext:Slider></Items>
                    </ext:Toolbar>
                </TopBar></ext:GridPanel>
    
    CODE BEHIND:
    
           protected void Page_Load(object sender, EventArgs e)
            {
               if (!IsPostBack)
                {
                    PagingSlider.Increment = 1000;
                    LoadGrid();
                }
            }
    
            public void cbTest_Change(object sender, DirectEventArgs e)
            {
                LoadGrid();
            }
    
            #region LoadGrid
            private void LoadGrid()
            {
                DataTable dt = LoadData(); // returns the data in DataTable
                BindData(0, PagingSlider.Increment, dt);
            }
            private void LoadGrid(int start, int limit)
            {
                DataTable dt = LoadData(); // returns the data in DataTable
                BindData(start, limit, dt);
            }
            #endregion
    
            #region BindData
            private void BindData(int start, int limit, DataTable dTable)
            {
                DataTable dt = dTable.Clone();
    
                if (limit > dTable.Rows.Count)
                {
                    limit = dTable.Rows.Count;
                    RangeText.Hidden = PagingSlider.Hidden = true;
                }
                else
                {
                    RangeText.Hidden = PagingSlider.Hidden = false;
                    PagingSlider.MaxValue = dTable.Rows.Count - PagingSlider.Increment;
                    RangeText.Text = "(1 - " + PagingSlider.Increment + ") of " + dTable.Rows.Count;
                }
    
                for (int i = start; i < start + limit; i++)
                    dt.ImportRow(dTable.Rows[i]);
    
                if (dt.Rows.Count == 0)
                {
                    GridPanel1.GetStore().ClearMeta();
                    GridPanel1.Reload();
                }
                else
                {
                    GridPanel1.GetStore().DataSource = dt;
                    GridPanel1.GetStore().DataBind();
                }
            }
            #endregion
    
            #region Store_Refresh
            protected void Store_Refresh(object sender, StoreRefreshDataEventArgs e)
            {
                int start = int.Parse(e.Parameters["startRemote"]);
                int limit = int.Parse(e.Parameters["limitRemote"]);
    
                DataTable dt = LoadData();
                e.Total = dt.Rows.Count;
                BindData(start, limit, dt);
            }
            #endregion
    When I try to filter the data by selecting the combo, it will filter records from 200K to 2000 records. Once I do that I cannot clear/update the data in grid. If I remove [RemotePaging="false"], I am able to clear/update the data, but I have all the 1000 records showing in the same page.

    Regards,
    Dan.
  4. #4
    PagingSlider.MaxValue = dTable.Rows.Count - PagingSlider.Increment;
    Also, can you please help me how to set the Maximum value to the slider from the codebehind. Since If I set the value as I mentioned above, then it is not working in some cases (if dTable.Rows.Count is 1400 and PagingSlider.Increment is 1200, I can see 1-1200, but not the remaining 200 rows since the Slider is disabled)

    Thanks in Advance.
  5. #5
    Quote Originally Posted by dnguyen View Post
    I am able to clear/update the data, but I have all the 1000 records showing in the same page.
    Please try to replace
    <BaseParams>
        <ext:Parameter Name="start" Value="0" Mode="Raw" />
        <ext:Parameter Name="limit" Value="15" Mode="Raw" />
    </BaseParams>
    with

    <AutoLoadParams>
        <ext:Parameter Name="start" Value="0" Mode="Raw" />
        <ext:Parameter Name="limit" Value="15" Mode="Raw" />
    </AutoLoadParams>
  6. #6
    Hi Daniil,

    I tried the code as you suggested by replacing the baseparams with AutoloadParams and removed [RemotePaging="false"]. Result is, if the Datatable returns 0 rows, then it clears the data. And tried again to get some results, it is not working fine. It keeps on throwing the errors. I guess since it is because of AutoloadParams.

    How the Slider Max value works ? Can you suggest me the fix for that as well ? (If you want to know, how I set, please review the code again)
    Thanks !!

    Regards,
    Dan.
  7. #7
    Quote Originally Posted by dnguyen View Post
    I tried the code as you suggested by replacing the baseparams with AutoloadParams and removed [RemotePaging="false"]. Result is, if the Datatable returns 0 rows, then it clears the data. And tried again to get some results, it is not working fine. It keeps on throwing the errors. I guess since it is because of AutoloadParams.
    Please use
     if (!IsPostBack && !X.IsAjaxRequest)
    It the issue still persists, please provide a full sample to reproduce. I can't run the code that you posted, because there are no LoadData() and RangeText.


    Quote Originally Posted by dnguyen View Post
    How the Slider Max value works ? Can you suggest me the fix for that as well ? (If you want to know, how I set, please review the code again)
    Please just change the .MaxValue property.
    Slider1.MaxValue = 1500;
  8. #8
    <script type="text/javascript">
        var remoteLoad = function (grid) {
            grid.body.mask("Loading...", "x-mask-loading");
    
            grid.store.load({
                callback: function () {
                    grid.body.unmask();
                }
            });
        };
    </script>
    <ext:Panel ID="Panel1" runat="server">
        <Content>
            <ext:ComboBox ID="cbFacility" runat="server"
                        DisplayField="Display" ValueField="Data"
                        FieldLabel="Facility"
                        ForceSelection="true"
                        AllowBlank="true"
                        Width="400">
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                        <Reader>
                            <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="Data" Mapping="Data"/>
                                <ext:RecordField Name="Display" Mapping="Display"/>
                            </Fields>
                            </ext:ArrayReader>
                        </Reader>
                        </ext:Store>
                    </Store>
                    <Triggers>
                        <ext:FieldTrigger Icon="Clear" Qtip="Remove selected" />
                    </Triggers>
                    <Listeners>
                        <TriggerClick Handler="this.clearValue();" />
                    </Listeners>
                    <DirectEvents>
                        <Select OnEvent="cbFacility_Change">
                            <EventMask ShowMask="true" />
                        </Select>
                        <TriggerClick OnEvent="cbFacility_Change">
                            <EventMask ShowMask="true" />
                        </TriggerClick>
                    </DirectEvents>
                </ext:ComboBox>
            <ext:GridPanel
                ID="GridPanel1" 
                runat="server"
                Collapsible="false"
                AutoWidth="true"
                Height="425"
                Frame="true">
                <Store>
                    <ext:Store runat="server" OnRefreshData="Store_Refresh" RemotePaging="false">
                        <Reader>
                            <ext:JsonReader>
                                <Fields>
                                    <ext:RecordField Name="Person" Mapping="PERSON" />
                                    <ext:RecordField Name="Dept" Mapping="TITLE" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <BaseParams>
                            <ext:Parameter Name="startRemote" Value="#{PagingSlider}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="limitRemote" Value="#{PagingSlider}.increment" Mode="Raw" />
                        </BaseParams>
                        <AutoLoadParams>
                            <ext:Parameter Name="start" Value="0" Mode="Raw" />
                            <ext:Parameter Name="limit" Value="5" Mode="Raw" />
                        </AutoLoadParams>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column DataIndex="Person" Header="Person" />
                        <ext:Column DataIndex="Dept" Header="Department" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GroupingView  
                        ID="GroupingView1"
                        runat="server" EnableGrouping="false"
                        ForceFit="true"
                        StartCollapsed="true"
                        GroupTextTpl='<span id="ColorCode-{[values.rs[0].data.ColorCode]}"></span>{text} (Count: {[values.rs.length]})'
                        EnableRowBody="true">
                    </ext:GroupingView>
                </View>
                <LoadMask ShowMask="true" />
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Slider ID="PagingSlider" runat="server" FieldLabel="# Records"
                                MinValue="0"
                                Width="400">
                                <Plugins>
                                    <ext:SliderTip ID="SliderTip1" runat="server" />
                                </Plugins>
                                <Listeners>
                                    <Change Handler="#{RangeText}.setText((newValue+1) + '-' + (newValue + #{PagingSlider}.increment) + ' of ' + #{PagingSlider}.maxValue)" />
                                    <ChangeComplete Handler="remoteLoad(#{GridPanel1});" />
                                </Listeners>
                            </ext:Slider>
                            <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                            <ext:ToolbarTextItem ID="RangeText" runat="server" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="5" />
                </BottomBar>
            </ext:GridPanel>
        </Content>
        </ext:Panel>
    Code behind:
    
    #region Page_Load
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack && !X.IsAjaxRequest)
                {
                    cbFacility.Clear();
                    cbFacility.GetStore().DataSource = new CommonBLL().GetFacilityList();
                    cbFacility.GetStore().DataBind();
    
                    PagingSlider.Increment = 1000;
                    LoadGrid();
                }
            }
            #endregion
    
            #region cbFacility_Change
            protected void cbFacility_Change(object sender, DirectEventArgs e)
            {
                LoadGrid();
            }
            #endregion
    
            #region Grid Methods
            #region LoadGrid
            private void LoadGrid()
            {
                DataTable dt = LoadData();
                BindData(0, PagingSlider.Increment, dt);
            }
            private void LoadGrid(int start, int limit)
            {
                DataTable dt = LoadData();
                BindData(start, limit, dt);
            }
            #endregion
    
            #region LoadData
            private DataTable LoadData()
            {
                string selectedFacility = cbFacility.SelectedItem.Value;
    
                ReportDAO rDAO = new ReportDAO(GetDBAlias());
                
                // This is where it returns the 200K records as DataTable if the filter is not set.
                return rDAO.SelectPastDueForTracker(selectedFacility, string.Empty, string.Empty, string.Empty);
            }
            #endregion
    
            #region BindData
            private void BindData(int start, int limit, DataTable dTable)
            {
                DataTable dt = dTable.Clone();
    
                if (limit > dTable.Rows.Count)
                {
                    limit = dTable.Rows.Count;
                    RangeText.Hidden = PagingSlider.Hidden = true;
                }
                else
                {
                    RangeText.Hidden = PagingSlider.Hidden = false;
                    PagingSlider.MaxValue = dTable.Rows.Count - PagingSlider.Increment;
                    if (!IsPostBack)
                        RangeText.Text = "1 - " + PagingSlider.Increment + " of " + dTable.Rows.Count;
                }
    
                for (int i = start; i < start + limit; i++)
                    dt.ImportRow(dTable.Rows[i]);
    
                if (dt.Rows.Count == 0)
                {
                    GridPanel1.GetStore().ClearMeta();
                    GridPanel1.Reload();
                }
                else
                {
                    GridPanel1.GetStore().DataSource = dt;
                    GridPanel1.GetStore().DataBind();
                }
            }
            #endregion
    
            #region Store_Refresh
            protected void Store_Refresh(object sender, StoreRefreshDataEventArgs e)
            {
                int start = int.Parse(e.Parameters["startRemote"]);
                int limit = int.Parse(e.Parameters["limitRemote"]);
    
                DataTable dt = LoadData();
                e.Total = dt.Rows.Count;
                BindData(start, limit, dt);
            }
            #endregion
            #endregion
    Above is the full sample to reproduce.
    For eg., As soon as the grid loads 200K records. If you apply the filter, filter has 4 alues, first value will filter the grid to 199K records, 2nd will filter to 1K records, 3rd and 4th will return 0 records.

    And for the slider Max Value, I need to implement it dynamically. I cannot hard code the value, since the records will be loaded dynamically according to the filter (Please see the code [PagingSlider.MaxValue = dTable.Rows.Count - PagingSlider.Increment;]).

    Thanks in Advance.

    Regards,
    Dan.
  9. #9
    What are the following things?
    new CommonBLL().GetFacilityList();
    ReportDAO rDAO = new ReportDAO(GetDBAlias());
    Please clarify how to run the page without these things?
    Last edited by Daniil; Apr 01, 2011 at 5:28 PM.
  10. #10
    Hi Danill,


    This line
    new CommonBLL().GetFacilityList();
    is being used to get a list of Facility from our database, which CommonBLL is the Business Logic Layer.


    This line
    ReportDAO rDAO = new ReportDAO(GetDBAlias());
    is being used to create an instance of the Report Data Access Object (hint: ReportDAO). The GetDBAlias() is the neccessary credential to use to create an instance of ReportDAO object.

    Moreover, the following line returns the 200K records as DataTable if the filter is not set

    return rDAO.SelectPastDueForTracker(selectedFacility, string.Empty, string.Empty, string.Empty);
    Hope this help.

    Dan
    Last edited by Daniil; Apr 01, 2011 at 10:26 PM. Reason: Please use [CODE] tags
Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 11
    Last Post: Jun 13, 2012, 4:53 PM
  2. [CLOSED] GridPanel remote paging issue
    By jskibo in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Jan 31, 2011, 8:37 AM
  3. [CLOSED] Local data paging problem
    By Timur.Akhmerov in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 20, 2010, 11:33 AM
  4. [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
  5. [CLOSED] [1.0] Gridview local data paging with remote data
    By BerndDA in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 15, 2010, 10:29 AM

Tags for this Thread

Posting Permissions