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

Cannot select row after pagesize has changed

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 14 Sep 2012, 12:27 PM
Hi there,

I have a Radgrid with server-side databinding and an onneeddatasource-event. 
I want to change the pagesize dynamically in addiction to the mastertableview-size.
All looks good but when the TableView was updated with the new pagesize, i can't select the rows anymore...

The Script:
<script type="text/javascript">
    function GridCreated(sender, eventArgs) {
            //gets the main table scrollArea HTLM element  
            var scrollArea = document.getElementById(sender.get_element().id + "_GridData");
            var tvHeight = scrollArea.offsetHeight;
            var size = Math.floor(tvHeight / 64);
            //alert(size);
            var tableView = $find("<%= RadGridView.ClientID %>").get_masterTableView();
            tableView.set_pageSize(size);
    }
</script>

HTML-Code:
<telerik:RadGrid ID="RadGridView" AutoGenerateColumns="False" onitemdatabound="RadGridViewItemDataBound" OnItemCreated="RadGridViewItemCreated" AllowSorting="True" AllowPaging="True" EnableViewState="True" OnPageIndexChanged="RadGridPageIndexChanged" OnNeedDataSource="RadGridView_NeedDataSource" runat="server">
<PagerStyle Mode="NextPrev" Position="Bottom" AlwaysVisible="True" CssClass="RadGridPager" PagerTextFormat="Seite blättern: {4} Seite {0} / {1} - Einträge {2} - {3} / {5}"/>
<ClientSettings>
    <Selecting AllowRowSelect="true" />
    <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" />
    <ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
<MasterTableView TableLayout="Fixed" Font-Size="18px" ClientDataKeyNames="IsBlueLight,IsFailure,IsStopped,OrderNr,ObjectNr" DataKeyNames="OrderNr">
    <NoRecordsTemplate>
        <div>
            Keine Einträge
        </div>
    </NoRecordsTemplate>
    <Columns>
         .........
</telerik:RadGrid>

Code-Behind:
....
protected void RadGridView_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    RadGridView.DataSource = Session[Constants.ORDERLIST] as List<Auftrag>;
}
....


thanking you in anticipation

Best regards,
Markus 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 19 Sep 2012, 08:17 AM
Hi Markus,

Note that this property is used with client-side data-binding. You cannot change the page size of a server-bound RadGrid on the client.
You could try the other way around - make the master table as high, as its fixed number of items currently are. For example, if you have a page size of 10 but the item height varies, you can use the following setting to make the grid auto-size to fit its content:
<ClientSettings>
    <Scrolling AllowScroll="true" ScrollHeight="" />
</ClientSettings>


Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Markus
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or