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

Set Scroll Height by PageSizeCombo selected

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rik butcher
Top achievements
Rank 1
rik butcher asked on 20 Dec 2014, 04:04 PM
guys, i'd like to be able to switch the ScrollHeight in the code behind based on the pageSize selected on the grid
we do this OnItemDataBound event and set the page size seletable to 15 & 30
if (e.Item is GridPagerItem)
{
RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
PageSizeCombo.Items.Clear();
PageSizeCombo.Items.Add(new RadComboBoxItem("15"));
PageSizeCombo.FindItemByText("15").Attributes.Add("ownerTableViewId", InventoriesRadGrid.MasterTableView.ClientID);
PageSizeCombo.Items.Add(new RadComboBoxItem("30"));
PageSizeCombo.FindItemByText("30").Attributes.Add("ownerTableViewId", InventoriesRadGrid.MasterTableView.ClientID);
PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
}
i've tried to punch into the events of the pagesizecombobox but it's not working - ANY IDEAS/ IM SURE IM MISSING SOMETHING SIMPLE
thanks
rik

2 Answers, 1 is accepted

Sort by
0
rik butcher
Top achievements
Rank 1
answered on 20 Dec 2014, 09:16 PM
ok, i think i've got this. if anyone knows of a more elegant way to do it, i'm open.

i hardcode: 
ScrollHeight="610px" in the client settings in the grid then add:

OnPageSizeChanged="PageChange" in the grid and use this & it seems to align w/ t he 15 or 30 row heights perfectly.


protected void PageChange(object sender, GridPageSizeChangedEventArgs e)
{
int newSize = e.NewPageSize;
if (newSize == 15)
{
InventoriesRadGrid.ClientSettings.Scrolling.ScrollHeight = 610;
}
else
{
InventoriesRadGrid.ClientSettings.Scrolling.ScrollHeight = 1320;
}
}
0
Konstantin Dikov
Telerik team
answered on 24 Dec 2014, 03:46 PM
Hello Rik,

Handling the server-side OnPageSizeChanged event of the grid is the correct event for changing the ScrollHeight in your scenario. 

Generally, you do not need to search for the RadComboBox control and you can just use the event arguments and the e.NewPageSize in particular:
protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
    int pageSize = e.NewPageSize;
    double value = RadGrid1.ClientSettings.Scrolling.ScrollHeight.Value;
     
    if (pageSize == 15)
    {
        RadGrid1.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(610);
    }
    else
    {
        RadGrid1.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(1220);
    }
}

If you have other questions, please feel free to get back to us.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
rik butcher
Top achievements
Rank 1
Answers by
rik butcher
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or