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

Pager RadComboBox Customization Issue

5 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laurie
Top achievements
Rank 2
Laurie asked on 16 Feb 2010, 03:51 PM
Hi,

I'm trying to set the pager radcombobox in my grid to populate itself with values from my web.config file.  This is working, except that the following is happening: when I change my number of items to show on one page from 10 to 2 (for testing; I only have 7 items in the grid) two items show up, but when I try to navigate through the grid, it resets itself to 10 and I get an empty grid, (i.e., if I click the next button it thinks it's on page 2 but it also thinks that there's only one page there, so it shows nothing).  When I click back to page 1, it shows all my records.  Here's the code:

ASPX:
    <telerik:RadGrid ID="rgUsers" runat="server" 
        OnNeedDataSource="rgUsers_NeedDataSource" OnItemCreated="rgAdminUsers_ItemCreated">  
        <MasterTableView DataKeyNames="UserName">  
            <Columns> 
                <telerik:GridCheckBoxColumn DataField="IsOnline" DataType="System.Boolean" 
                    HeaderText="Is Online?" UniqueName="IsOnline" > 
                </telerik:GridCheckBoxColumn> 
                <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="LastLoginDate" HeaderText="Last Logged In" UniqueName="column">  
                </telerik:GridBoundColumn> 
                <telerik:GridTemplateColumn HeaderText="Is Approved?" UniqueName="IsApproved" SortExpression="IsApproved" DataField="IsApproved">  
                    <ItemTemplate> 
                        <asp:CheckBox ID="cbIsApproved" runat="server" AutoPostBack="true" Checked='<%# Bind("IsApproved") %>'   
                            OnCheckedChanged="gvUsers_UpdateIsApproved"  /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Is Locked Out?" UniqueName="IsLockedOut" SortExpression="IsLockedOut" DataField="IsLockedOut">  
                    <ItemTemplate> 
                        <asp:CheckBox ID="cbIsLockedOut" runat="server" AutoPostBack="true" Checked='<%# Bind("IsLockedOut") %>'   
                            OnCheckedChanged="gvUsers_UpdateLockedOut" Enabled='<%# Bind("IsLockedOut") %>' /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Role(s)" UniqueName="Roles" DataField="Roles" AllowFiltering="False">  
                    <ItemTemplate> 
                        <%# String.Join(", ",Roles.GetRolesForUser(DataBinder.Eval(Container.DataItem, "UserName").ToString())) %> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn HeaderText="Petition(s)" UniqueName="Petitions" DataField="Petitions" AllowFiltering="False">  
                    <ItemTemplate> 
                        <%# new ProfileCommon().GetProfile(DataBinder.Eval(Container.DataItem, "UserName").ToString()).Petitions.Replace(", ","<br />") %> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn" AllowFiltering="False">  
                    <ItemTemplate> 
                        <asp:Button ID="btnEditRoles" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="EditRoles" Text="Edit Roles" OnClick="EditRoles" /> 
                        <asp:Button ID="btnEditPetitions" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="EditRoles" Text="Edit Petitions" OnClick="EditPetitions" /> 
                        <asp:Button ID="btnChangePassword" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="ChangePassword" Text="Change Password" OnClick="ChangePassword" /> 
                        <asp:Button ID="btnUserInfo" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName").ToString() %>' 
                            CommandName="ViewUserInfo" Text="View User Info" OnClick="ViewUserInfo" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 
 

CS:
    protected void rgAdminUsers_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        // Pull Number of Entries per page in page from web.config appsettings.  
        if (e.Item is GridPagerItem)  
        {  
            RadComboBox myPageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");  
            myPageSizeCombo.Items.Clear();  
            string strPageSizes = ConfigurationManager.AppSettings["PageSizes"];  
            string[] arrPageSizes = strPageSizes.Split(',');  
            for (int x = 0; x < arrPageSizes.Length; x++)  
            {  
                RadComboBoxItem myRadComboBoxItem = new RadComboBoxItem(arrPageSizes[x]);  
                myPageSizeCombo.Items.Add(myRadComboBoxItem);  
                myPageSizeCombo.FindItemByText(arrPageSizes[x]).Attributes.Add("ownerTableViewId", rgUsers.MasterTableView.ClientID);   
            }  
            myPageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;  
        }  
    }  
 

5 Answers, 1 is accepted

Sort by
0
Laurie
Top achievements
Rank 2
answered on 17 Feb 2010, 07:58 PM
Anyone out there?
0
Accepted
Martin
Telerik team
answered on 19 Feb 2010, 02:50 PM
Hello Laurie,

I have attached a small sample project demonstrating how to change the default combo items with user defined ones.

I hope this helps,
Martin
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.
0
Laurie
Top achievements
Rank 2
answered on 19 Feb 2010, 09:46 PM
Martin,

No, the code you sent does not work as desired/expected.  It seems to want to remember the value of the pagesize from when we first enter the page.  So, when I change it, for example, from 2 to 10, it shows me 10 records.  Then when I click next, it sets the pagesize back to 2 and shows me 2 records on the page.  Should I submit a support ticket? 

Laurie

p.s.  FYI: In order to get your code to run at all I had to remove the linq include and add AutoGenerateColumns='true' to the radgrid tag.  I'm running asp.net 2.0 without linq.
0
Martin
Telerik team
answered on 24 Feb 2010, 01:28 PM
Hello Laurie,

I double tested the sample project from my previous post and it ran as expected on my side. Indeed you are correct that the "Linq" namespace should be removed from the code-behind when ASP .NET 2.0 project us used. However the AutoGenerateColumns property default value is "true" and you can skip its declaration in the markup.

In order to continue with resolving the problem I would suggest you to open a formal support ticket and send me a small runnable example demonstrating the erratic behavior. You can also use the test project from my previous post if you find it more appropriate. Please do not forget to provide detailed step-by-step instructions on how to reproduce the issue.

Regards,
Martin
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.
0
Laurie
Top achievements
Rank 2
answered on 24 Feb 2010, 03:58 PM
Doh!  Figured it out.  I have a RadGrid skin in my App_Themes folder that had the following code:

 

 

   <telerik:RadGrid runat="server" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="true"   
        GridLines="None" AutoGenerateColumns="False" Skin="Default" PagerStyle-AlwaysVisible="true"   
        PagerStyle-PageSizeLabelText="Number of entries per page:" PagerStyle-EnableSEOPaging="true">  
        <GroupingSettings CaseSensitive="false" /> 
                <AlternatingItemStyle VerticalAlign="Top" /> 
        <ItemStyle VerticalAlign="Top" /> 
</telerik:RadGrid> 
 

 


When I removed the setting PagerStyle-EnableSEOPaging="true", the grid worked just as expected.  (This also explains why it was defaulting to AutoGenerateColumns="False".)

Thanks for the help.

Laurie

Tags
Grid
Asked by
Laurie
Top achievements
Rank 2
Answers by
Laurie
Top achievements
Rank 2
Martin
Telerik team
Share this question
or