This is a migrated thread and some comments may be shown as answers.

paging not working for dynamically bound grid

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 22 Jun 2010, 05:16 PM
I have a radgrid that is bound dynamically within the code, the page size is set to 10 as you can see below, however
the paging isn't working correctly. All the rows are displayed and there is no option to page to the next page.

the grid is bound on the click of a button with the following code

       grv_cand_shifts.DataSource = swaps.tbl_shifts_to_give_away;
            grv_cand_shifts.DataBind();





          
please can you help.


 <telerik:RadGrid ID="grv_cand_shifts" runat="server" AllowFilteringByColumn="True" AllowCustomColumns="True" AllowCustomPaging="True"
                AllowPaging="True" ExportSettings-ExportOnlyData="true" ExportSettings-IgnorePaging="true" HeaderStyle-Wrap="true"
                AllowSorting="True" GridLines="None" AutoGenerateColumns="False" Skin="<%$ AppSettings:TelerikControlSkin %>"
                Width="100%" OnPreRender="grv_my_shifts_OnPreRender" OnDataBound="grv_cand_shifts_DataBound" PageSize="10" Message="" OnNeedDataSource="grv_cand_shifts_NeedDataSource" >
                <MasterTableView DataKeyNames="id" Width="100%"  >
                    <Columns>
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                        </telerik:GridClientSelectColumn>
                        <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" UniqueName="id"
                            Visible="False">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="shift_date" HeaderText="Shift date" ReadOnly="True"
                            UniqueName="shift_date" DataFormatString="{0:dd/MM/yyyy}">
                        </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="start_time" ReadOnly="True" Visible="False" UniqueName="start_time"
                            HeaderText="Start Time">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="end_time" Visible="False" UniqueName="end_time"
                            HeaderText="End Time">
                            </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="person" HeaderText="Person" UniqueName="person"
                            SortExpression="person">
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="rota_period_id" DataSourceID="sql_rota_period"
                            HeaderText="Rota period" ListTextField="label" ListValueField="id" UniqueName="rota_period_id">
                            <filtertemplate>
                                            <telerik:RadComboBox ID="RadComboPeriod2" DataSourceID="sql_rota_period" DataTextField="label"
                                                DataValueField="id" AppendDataBoundItems="true" SelectedValue='<%#  ((GridItem)Container).OwnerTableView.GetColumn("rota_period_id").CurrentFilterValue %>'
                                                runat="server" OnClientSelectedIndexChanged="Period2Changed">
                                                <Items>
                                                    <telerik:RadComboBoxItem Text="All" />
                                                </Items>
                                            </telerik:RadComboBox>
                                            <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">

                                                <script type="text/javascript">
                                    function Period2Changed(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("rota_period_id", args.get_item().get_value(), "EqualTo");
                                    }
                        </script>
                    </telerik:RadScriptBlock>                    
                        
</filtertemplate>
                        </telerik:GridDropDownColumn>
                        <telerik:GridBoundColumn DataField="email" HeaderText="Contact" ReadOnly="True" UniqueName="email" Visible="False">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings >
                    <Selecting AllowRowSelect="True" />
                    <ClientEvents OnFilterMenuShowing="filterMenuShowing" OnGridCreated="getGridObject" />
                </ClientSettings>
                  <PagerStyle AlwaysVisible="True" Mode="NumericPages" />
                <ExportSettings ExportOnlyData="True" IgnorePaging="True">
                </ExportSettings>
              
                <FilterMenu OnClientShown="MenuShowing">
                </FilterMenu>
                <HeaderStyle Wrap="True" />
              
            </telerik:Radgrid>&nbsp;

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Jun 2010, 12:15 PM
Hello Robert,

Instead of binding the grid conditionally using simple binding with DataBind() calls, you can transform your code to take advantage of the advanced binding with NeedDataSource handling. Thus you will be able to utilize features like paging, grouping, filtering, custom edit forms which are supported only with this type of binding or declarative data sources.

Give this suggestion a try and let me know how it goes.

Greetings,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or