Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
139 views

Here is my environment Specs:

  1. ASP.NET 2.0
  2. Microsoft Windows XP Professional Version 2002 SP2
  3. IE V 7
  4. Telerik Q2 2008 
  5. C#

I have a radgrid that has more than one page of data to show, the data on the page is being filled correctly, and I am limiting it to 20 records per page. I am using both the numbers href links to page through the grid and the arrow, as more data is available to be shown. When I click on the page number or arrow to page through the data in the rad grid I get the following error (also in green where it happens on my code behind snippet down below):

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

My debug triggers the error on the codebehind on this line, in the rgUsers_ItemCommand() when I try to page to the next 20 records:
string sUserName = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserName"].ToString();

Do I need to do a conditional check to make sure that the rgUsers table has a row count greater than zero? Or is there some property I am not using to allow this? My dataset returns 30 users so I expect to see at least 10 users on page 2 of the radgrid.

Code from the aspx Page:

 

 

 

<telerik:RadGrid ID="rgUsers" Skin="Office2007" runat="server" AllowPaging="True" 
                        PageSize="20" AllowSorting="True" Width="100%" AutoGenerateColumns="False" OnNeedDataSource="rgUsers_OnNeedDataSource" 
                        OnPreRender="rgUsers_PreRender" OnDeleteCommand="rgUsers_DeleteCommand" OnItemCommand="rgUsers_ItemCommand" GridLines="None">  
                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> 
                        <MasterTableView CommandItemDisplay="None" GridLines="None" DataKeyNames="UserName">  
                            <RowIndicatorColumn Visible="False">  
                                <HeaderStyle Width="20px" /> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn Visible="False">  
                                <HeaderStyle Width="19px" /> 
                            </ExpandCollapseColumn> 
                            <Columns> 
                                <telerik:GridEditCommandColumn> 
                                </telerik:GridEditCommandColumn> 
                                <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="Email" HeaderText="Email" UniqueName="Email">  
                                    <HeaderStyle Width="25%" /> 
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="LastActivityDate" HeaderText="Last Activity Date" 
                                    UniqueName="LastActivityDate">  
                                    <HeaderStyle Width="15%" /> 
                                </telerik:GridBoundColumn> 
                                <telerik:GridCheckBoxColumn DataField="IsApproved" HeaderText="Approved" UniqueName="IsApproved">  
                                    <HeaderStyle Width="12%" /> 
                                </telerik:GridCheckBoxColumn> 
                                <telerik:GridCheckBoxColumn DataField="IsLockedOut" HeaderText="Locked Out" UniqueName="IsLockedOut">  
                                    <HeaderStyle Width="12%" /> 
                                </telerik:GridCheckBoxColumn> 
                                <telerik:GridTemplateColumn UniqueName="TemplateColumn1">  
                                    <ItemTemplate> 
                                        &nbsp;<asp:LinkButton ID="lnkBtnDelete" runat="server" CausesValidation="false" CommandName="Delete" 
                                            ForeColor="#044A7E" Text="Delete" Visible='<%# DelButShowHide((DataBinder.Eval (Container.DataItem, "UserName").ToString())) %>'></asp:LinkButton> 
                                    </ItemTemplate> 
                                    <HeaderStyle Width="8%" /> 
                                </telerik:GridTemplateColumn> 
                            </Columns> 
                            <EditFormSettings> 
                                <EditColumn UniqueName="EditCommandColumn1">  
                                </EditColumn> 
                            </EditFormSettings> 
                        </MasterTableView> 
                        <HeaderStyle HorizontalAlign="Left" /> 
                        <FilterMenu EnableTheming="True" Skin="Office2007">  
                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                        </FilterMenu> 
                        <SortingSettings SortedAscToolTip="/Manager/images/arrw_up.gif" SortedDescToolTip="/Manager/images/arrw_d.gif" /> 
                    </telerik:RadGrid> 

 

 

Code from the aspx.cs code behind:

 

 

 

protected void rgUsers_ItemCommand(object source, GridCommandEventArgs e)  
    {  
 
        //Errors out on this line :Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index  
         string sUserName = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserName"].ToString();  
        //End Error out on this line  
 
        MembershipUser oUser = Membership.GetUser(sUserName);  
        DisplayMessage(string.Empty);  
 
        if (e.CommandName == RadGrid.EditCommandName)//Edit a user  
        {  
            e.Canceled = true;//interrupts the rgUsers commands so that it does not show inline edit forms  
              
            hdnSubmitType.Value = "UpdateUser";  
            PageMode = mode.form;  
            RolePrivPanelMode = RolePrivMode.roleChoice; //sets default to role selected  
            tbUserName.Enabled = false;  
            hydrateEditForm(oUser);  
            buildRadTrees(UserInfo.UserIdentityKey.ToString(), oUser.ProviderUserKey.ToString());  
              
            UserInfo.UserIdentityKey.ToString());  
            CheckedRadTreesNodes(oUser);  
            RolePrivPanelMode = RolePrivMode.roleChoice; //set Roles panel to be shown  
 
        }  
    } 

 

 

 

 

 

Eric
Top achievements
Rank 1
 answered on 25 Nov 2008
1 answer
154 views
I have a RadComboBox is inside a PagerTemplate within a grid.  Sometimes OnSelectedIndexchanged is called with the incorrect sender and incorrect new value.  ie if i change the combobox on the top the bottom one is passed in.   In the case of the aspx i have below OnSelectedIndexchanged is called with the wrong values.

In particular when combbox is set to the default value(value that it gets set to when first visiting the page) the wrong value is passed in.

Thanks in advance,
Calvin

ps. Below is the a snippet of what i have in the aspx page and the method called when the index is changed:

<telerik:RadGrid ID="RadGrid1"  runat="server"
            Skin="Office2007"
            AllowPaging="True"
            AllowCustomSorting="true"
            PagerStyle-AlwaysVisible="true"
            AllowSorting="True"
            GridLines="None"  
            AutoGenerateColumns="false"
            OnNeedDataSource="RadGid1_NeedDataSource"
            OnItemDataBound="RadGrid1_ItemDataBound"
            OnItemCommand="RadGrid1_ItemCommand"
            OnItemCreated="RadGrid1_ItemCreated"
            OnColumnCreated="RadGrid1_ColumnCreated"
            ShowStatusBar="false"
            ShowHeader="false"
            ClientSettings-Resizing-AllowColumnResize="true"
            >

    <MasterTableView  GroupLoadMode="Client"  >
        <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField  HeaderText="&nbsp;&nbsp;&nbsp;&nbsp;" HeaderValueSeparator="" FieldAlias="Events" FieldName="Day" FormatString="{0:dddd, MMMM d, yyyy}"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="Day" SortOrder="Ascending"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="viewDetails" ButtonType="ImageButton"  EditImageUrl="../Images/plus.png">
            </telerik:GridEditCommandColumn>
            <telerik:GridTemplateColumn UniqueName="SingleColumn">
                <ItemTemplate>
                    <!-- Items -->                      
                    </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <CHO:TemplateViewer id="templateViewer" runat="server" MiniTemplate="true" />
                    </FormTemplate>
                </EditFormSettings>
                <PagerTemplate>
                    <asp:Panel ID="PagerPanel" Style="padding: 6px;" runat="server">
                    <telerik:RadComboBox id="cbSort" runat="server"  AutoPostBack="true" OnSelectedIndexChanged="cbSort_OnIndexChanged" EnableViewState="true">
                        <Items>
                            <telerik:RadComboBoxItem Text="Event Date" Value="Day" />
                            <telerik:RadComboBoxItem Text="Event Name" Value="EventName" />
                            <telerik:RadComboBoxItem Text="Category" Value="CategoryName" />
                        </Items>
                    </telerik:RadComboBox>                            
                        <div class="listPageNumber">                        
                            <asp:Panel runat="server" ID="NumericPagerPlaceHolder" >  </asp:Panel>
                        </div>
                        <div class="listPageSize">                            
                            <span class="listPageSizeText">Page size:</span>
                            <telerik:RadComboBox ID="cbPaging" DataSource="<%# new object[]{10, 20, 30, 40, 50} %>"
                                Skin="Office2007" SelectedValue='<%# DataBinder.Eval(Container, "Paging.PageSize") %>'
                                runat="server" OnClientSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                            </telerik:RadComboBox>
                        </div>
                    </asp:Panel>
                </PagerTemplate>
                <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="TopAndBottom" ShowPagerText="false"   ></PagerStyle>
               </MasterTableView>
        </telerik:RadGrid>

-------------------------- code behind----------------

protected void cbSort_OnIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadGrid1.MasterTableView.GroupByExpressions.Clear();
            RadGrid1.MasterTableView.SortExpressions.Clear();
            
            var group = new GridGroupByExpression();
            var field = new GridGroupByField();

            switch (e.Value)
            {
                case DayFieldName:
                   /*set sorting and grouping*/
                    break;
                case CategoryFieldName:
                   /*set sorting and grouping*/
                    break;
                case EventFieldName:
                   /*set sorting and grouping*/
                    break;
                default:
                   /*set sorting and grouping*/
                    break;
            }
            RadGrid1.MasterTableView.Rebind();

            //Selects the correct item in the combo box based on the new value
            ((RadComboBox) RadGrid1.MasterTableView.GetItems(GridItemType.Pager)[0].FindControl("cbSort")).SelectedValue
                = e.Value;
            ((RadComboBox)RadGrid1.MasterTableView.GetItems(GridItemType.Pager)[1].FindControl("cbSort")).SelectedValue
                = e.Value;
        }
Calvin
Top achievements
Rank 1
 answered on 25 Nov 2008
1 answer
143 views

Hi
I am using menu as a context menu on grid.

I am inserting a new menu item at runtime from JavaScript. My problem is that the Menu does not disappear after on click event.

var

 

childItem = new Telerik.Web.UI.RadMenuItem();

 

 

 

 

 

childItem.set_text(strOption);

childItem._click = AdjustOwner_LoadDropdown; // AdjustOwner_LoadDropdown is a function

menu.get_items().insert(2, childItem);

Am I missing setting some property?

 

 

 

 

 

 

 

Punit
Top achievements
Rank 1
 answered on 25 Nov 2008
2 answers
140 views
Hi

I need to add or remove a menu item depending upon some comdiitons in javascript. I found no trouble finding menu object in javascript, I was able to remove an item as well with the help of 

menu._childListElement.removeChild(menu._childListElement.childNodes[4]);

but I could not find a way to add a menu item into it. There are functions like apendchild(child), but I am not able to figure out first how to create a child to pass that as parameter.

Is there a way to do add an item?
Punit
Top achievements
Rank 1
 answered on 25 Nov 2008
1 answer
106 views
Hi,

I am trying to put RadPanelBar into "My Portal" example. So I opened the sample project, edited \Dock\Examples\Default\ExchangeRates.ascx as following:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ExchangeRates.ascx.cs" 
    Inherits="Dock_Examples_Default_ExchangeRates" %> 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<br /> 
Base currency:  
<br /> 
<asp:DropDownList runat="server" ID="BaseCurrencyList" EnableViewState="false" /> 
<br /> 
<br /> 
Foreign currency:  
<br /> 
<asp:DropDownList runat="server" ID="ForeignCurrencyList" EnableViewState="false" /> 
<br /> 
<br /> 
<asp:Button runat="server" ID="SubmitBtn" Text="Calculate Rate" OnClick="SubmitBtn_Click" /> 
<br /> 
<br /> 
<telerik:RadPanelBar ID="uxMenuBar" runat="server" BorderStyle="None" BorderWidth="0px" 
    EnableTheming="True" ExpandMode="FullExpandedItem" Height="200px" PersistStateInCookie="True" 
    Skin="Outlook" Width="100%" OnItemClick="uxMenuBar_ItemClick">  
    <CollapseAnimation Type="None" Duration="100"></CollapseAnimation> 
    <Items> 
        <telerik:RadPanelItem runat="server" Expanded="True" Text="Home">  
            <Items> 
                <telerik:RadPanelItem runat="server" Text="Dashboard"
                </telerik:RadPanelItem> 
                <telerik:RadPanelItem runat="server" Text="Announcements">  
                </telerik:RadPanelItem> 
                <telerik:RadPanelItem runat="server" Text="Events">  
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelItem> 
        <telerik:RadPanelItem runat="server" Text="My Inbox">  
            <Items> 
                <telerik:RadPanelItem runat="server" Text="Inbox">  
                </telerik:RadPanelItem> 
                <telerik:RadPanelItem runat="server" Text="Compose">  
                </telerik:RadPanelItem> 
                <telerik:RadPanelItem runat="server" Text="Sent Messages">  
                </telerik:RadPanelItem> 
                <telerik:RadPanelItem runat="server" Text="Recycle Bin">  
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelItem> 
    </Items> 
    <ExpandAnimation Type="None" Duration="100"></ExpandAnimation> 
</telerik:RadPanelBar> 
<asp:UpdatePanel runat="server" ID="UpdatePanelHoroscopes">  
    <ContentTemplate> 
        <asp:Literal runat="server" ID="Result" /> 
    </ContentTemplate> 
    <Triggers> 
        <asp:AsyncPostBackTrigger ControlID="SubmitBtn" /> 
    </Triggers> 
</asp:UpdatePanel> 
<br /> 
 

Then I go to design view of ExchangeRates.ascx, double click the RadPanelBar I added to the page. The added RadPanelBar in code behind will looked like this:

    protected void uxMenuBar_ItemClick(object sender, Telerik.Web.UI.RadPanelBarEventArgs e)     
    {     
        System.Diagnostics.Debug.WriteLine("You Clicked: " + e.Item.Text);     
    }    
 

Now I press F5 to debug the sample. Browse to /Dock/Examples/MyPortal/DefaultCS.aspx, then click "Add Dock" button with "Select Module" default to ExchangeRates.ascx. After the PanelBar appears, click "My Inbox" and I am expecting it to expand, but the menu refuse to expand. Refresh the page will show "My Inbox" expanded but again if you now click "Home" menu, which is collapsed at this time it won't expand like it doesn't for "My Inbox" previously.

How can I make RadPanelBar work with MyPortal sample? Did I miss something?

Thanks!

Wei
Wei
Top achievements
Rank 1
 answered on 25 Nov 2008
3 answers
144 views
Before moving to the 2008 Q3 release, we had been using the rsLastSpacingWrapper class to minimize the vertical padding placed within each row/resource. Our css looked like the following:

div.RadScheduler .rsTimelineView .rsAllDayRow td .rsLastSpacingWrapper
{
    height: 5px;
    _height: 5px;
}

This worked properly. Now, with Q3, we are experiencing an issue in which this only resizes the first row/resource displayed. The cause is that only that first row/resource gets the rsLastSpacingWrapper placed on it. Specifically, this is what a td of the first row compared to the second row appear as:

First Row: <TD class="  rsEmptyTimeSlot rsAptCreate"><DIV class="rsWrap rsLastSpacingWrapper" style="HEIGHT: 25px"><!-- --></DIV></TD>

Second Row: <TD class="  rsEmptyTimeSlot rsAptCreate"><DIV class=rsWrap style="HEIGHT: 25px"><!-- --></DIV></TD>

This appears to be a bug, and it's keeping us from being able to size our schedule appropriately.

Also, a related question (though a smaller issue). How is the "Height: 25px" getting rendered to that div? I am having to add "!important" to my css to override this. I'm not sure if we have control over that style attribute or not.

Thanks in advance for a quick response!

Jeff
Peter
Telerik team
 answered on 25 Nov 2008
5 answers
160 views
Hi, I have a grid included in page and I saw that the default height for it is 300px. I want the grid to readjust it's size depending on the number of records it contains. This default height is put into the inner classes of the grid? It cannot be replaced. It would be nice to have a readjustment of the height depending on the number of rows. What can I do? Any ideas?
Thank you.
Dimo
Telerik team
 answered on 25 Nov 2008
1 answer
157 views
Hi guys, I am trying to set a fixed size of a rad grid column to prevent the columns get resized on each page (paging enabled) - depending on their content.

The other thing I want to accomplish is to restrict the grid from displaying more than I specified - and if the content is too long it should get cut.

Is there a way to do this with a setting/property of the RadGrid, because I haven't found anything?

thank you very much, yours, Rene Weiss
Dimo
Telerik team
 answered on 25 Nov 2008
1 answer
119 views
Hello,
I have R.A.D Editor with its css class. I want to add hover state to the style that I use in the HyperLink Manager.
Can you give me an example how to do this.
Thanks in advance
Rumen
Telerik team
 answered on 25 Nov 2008
2 answers
102 views
I have the rad editor set up, deployed, and activated on a test machine to see if I can fix the cross browser compatibility.  I activated on my site and I can see it but for some weird reason I am unable to type anything in the editor.  Any ideas?  This is the latest version of the trial.

Thanks.
Michael
Top achievements
Rank 1
 answered on 25 Nov 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?