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

paging not working for dynamically bound grid

1 Answer 92 Views
This is a migrated thread and some comments may be shown as answers.
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;

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%"  >
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                        <telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" UniqueName="id"
                        <telerik:GridBoundColumn DataField="shift_date" HeaderText="Shift date" ReadOnly="True"
                            UniqueName="shift_date" DataFormatString="{0:dd/MM/yyyy}">
                               <telerik:GridBoundColumn DataField="start_time" ReadOnly="True" Visible="False" UniqueName="start_time"
                            HeaderText="Start Time">
                        <telerik:GridBoundColumn DataField="end_time" Visible="False" UniqueName="end_time"
                            HeaderText="End Time">
                        <telerik:GridBoundColumn DataField="person" HeaderText="Person" UniqueName="person"
                        <telerik:GridDropDownColumn DataField="rota_period_id" DataSourceID="sql_rota_period"
                            HeaderText="Rota period" ListTextField="label" ListValueField="id" UniqueName="rota_period_id">
                                            <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">
                                                    <telerik:RadComboBoxItem Text="All" />
                                            <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");
                        <telerik:GridBoundColumn DataField="email" HeaderText="Contact" ReadOnly="True" UniqueName="email" Visible="False">
                <ClientSettings >
                    <Selecting AllowRowSelect="True" />
                    <ClientEvents OnFilterMenuShowing="filterMenuShowing" OnGridCreated="getGridObject" />
                  <PagerStyle AlwaysVisible="True" Mode="NumericPages" />
                <ExportSettings ExportOnlyData="True" IgnorePaging="True">
                <FilterMenu OnClientShown="MenuShowing">
                <HeaderStyle Wrap="True" />

1 Answer, 1 is accepted

Sort by
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.

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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question