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

Paging ComboBox Items

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Appu
Top achievements
Rank 1
Appu asked on 07 Jul 2009, 08:38 AM
Hi
      I am using rad grid having paging option , i would like to change or customize  Paging Combobox items. I could only customize or add upto 3 items to that combo box.But i would like to add default sizes to be 25, 50, 100, 250, and 500 so on. is there any way to extend the items size up to the size i mentioned.

if (e.Item is GridPagerItem)
        {
            RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
            PageSizeCombo.Items[0].Text = "50";
            PageSizeCombo.Items[1].Text = "500";
            PageSizeCombo.Items[2].Text = "1000";
            //PageSizeCombo.Items[3].Text = "500";
            //PageSizeCombo.Items[4].Text = "2000";
           
            //PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
            PageSizeCombo.FindItemByText("50").Selected = true;

           
            
        }

In above code i could add only 3 items including the Page size i fixed in the Grid

Regards,
Appu

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jul 2009, 10:11 AM

Hi Appu,

I guess you are able to edit the existing and want to add more pagesize options in combobox. If so you can create radcomboitem dynamically with required values and add to pagesize combo items collection. See the example shown below.

C#:

 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridPagerItem)  
    {  
        RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");  
        PageSizeCombo.Items[0].Text = "25";  
        PageSizeCombo.Items[1].Text = "50";  
        PageSizeCombo.Items[2].Text = "100";  
        RadComboBoxItem item1 = new RadComboBoxItem("500","500");  
        item1.Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);  
        PageSizeCombo.Items.Add(item1);  // Adds new pagesize option  
        RadComboBoxItem item2 = new RadComboBoxItem("1000","1000");  
        item2.Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);  
        PageSizeCombo.Items.Add(item2);  // Adds new pagesize option  
        PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;   
    }  

Thanks,
princy.

0
Appu
Top achievements
Rank 1
answered on 07 Jul 2009, 11:39 AM
Hi
 suppose if i would like to cal client side event of PageCombo_SelectedIndexChanged, how it is possible. Because as per ur coding giben the Paging is not working correctly. Records are not preseinting correctly. So i hope it would be correct once ofter calling client side event of PageSize combo

 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">
        var tableView = null;
        function pageLoad(sender, args)
        {
            tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        }
        
        function PageCombo_SelectedIndexChanged(sender, args)
        {
            alert("aa");
            tableView.set_pageSize(sender.get_value());
        }
        
        function changePage(argument)
        {
            tableView.page(argument);
        }
So whether paging will work after calling this methods, if so how can i call this method by code.

Regards,
Appu



Tags
Grid
Asked by
Appu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Appu
Top achievements
Rank 1
Share this question
or