Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
315 views
I'm trying to get a RadComboBox to work in RadGrid FormTemplate.I'm getting this error:

Line: 15
Error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value

.aspx
<telerik:RadGrid ID="RadGrid1" runat="server"
                AllowFilteringByColumn="True"
                AllowPaging="True"
                AllowSorting="True"
                AutoGenerateColumns="False"
                DataSourceID="SqlDataSource1"
                OnItemDeleted="RadGrid1_ItemDeleted"
                OnItemInserted="RadGrid1_ItemInserted"
                OnItemUpdated="RadGrid1_ItemUpdated"
                GridLines="None"
                AllowAutomaticDeletes="True"
                AllowAutomaticInserts="True"
                AllowAutomaticUpdates="True">
                <GroupingSettings CaseSensitive="False"></GroupingSettings>
 
                <ClientSettings AllowColumnsReorder="True">
                    <Selecting AllowRowSelect="True" />
                    <Selecting AllowRowSelect="True"></Selecting>
                </ClientSettings>
                <GroupingSettings CaseSensitive="false" />
            <MasterTableView autogeneratecolumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="PushButton">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="s_page" DefaultInsertValue="" HeaderText="s_page" UniqueName="s_page" SortExpression="s_page">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="s_doc_title" DefaultInsertValue="" HeaderText="s_doc_title" UniqueName="s_doc_title" SortExpression="s_doc_title">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="s_doc_url" DefaultInsertValue="" HeaderText="s_doc_url" SortExpression="s_doc_url" UniqueName="s_doc_url">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="d_date_uploaded" DataType="System.DateTime" DefaultInsertValue="" HeaderText="d_date_uploaded" SortExpression="d_date_uploaded" UniqueName="d_date_uploaded">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="d_date_displayed" DataType="System.DateTime" DefaultInsertValue="" HeaderText="d_date_displayed" SortExpression="d_date_displayed" UniqueName="d_date_displayed">
                        </telerik:GridBoundColumn>
                        <telerik:GridCheckBoxColumn DataField="b_visible" DefaultInsertValue="" HeaderText="b_visible" UniqueName="b_visible" DataType="System.Boolean" SortExpression="b_visible">
                        </telerik:GridCheckBoxColumn>
                    </Columns>
                    <EditFormSettings ColumnNumber="3" CaptionFormatString="Edit details for {0}" CaptionDataField="id" EditColumn-ButtonType="PushButton" EditFormType="Template">
                    <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormTableStyle CellPadding="2" CellSpacing="0" GridLines="Horizontal" CssClass="module" Height="110px" Width="100%"></FormTableStyle>
                    <FormMainTableStyle CellPadding="3" CellSpacing="0" Width="100%"></FormMainTableStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" />
                    <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" CssClass="module" Height="110px" Width="100%" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle>
                    <EditColumn UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit" ButtonType="PushButton">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                    <FormTemplate>
                        <table cellspacing="0" cellpadding="0" border="0">
                            <tr>
                                <td width="400">
                                    <table cellspacing="0" cellpadding="0" border="0">
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="375" valign="top">
                                                ID:
                                            </td>
                                            <td>
                                                <asp:Label ID="lbl_id" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="375" valign="top">
                                                Page:
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="RadComboBox1" runat="server"
                                                    DataSourceID="SqlDataSource3"
                                                     DataTextField="MenuText"
                                                     DataValueField="MenuId"
                                                     SelectedValue='<%# Bind("s_page") %>'
                                                     Skin="Vista" AutoPostBack="True">
                                                </telerik:RadComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="375" valign="top">
                                                Doc. Title:
                                            </td>
                                            <td>
                                                <asp:TextBox Width="240px" ID="txtbx_title" runat="server" Text='<%# Bind("s_doc_title") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="375" valign="top">
                                                Date Uploaded:
                                            </td>
                                            <td>
                                                <asp:TextBox Width="240px" ID="TextBox3" runat="server" Text='<%# Bind("d_date_uploaded") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="375" valign="top">
                                                Date Displayed:
                                            </td>
                                            <td>
                                                <asp:TextBox Width="240px" ID="TextBox4" runat="server" Text='<%# Bind("d_date_displayed") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="400">
                                    <table>
                                        <tr>
                                            <td width="5">
                                            </td>
                                            <td width="90" valign="top">
                                                PDF File Name:
                                            </td>
                                            <td>
                                                <asp:TextBox Width="240px" ID="TextBox2" runat="server" Text='<%# Bind("s_doc_url") %>'></asp:TextBox>
                                                <asp:Button ID="btn_pdf_upload" runat="server" Text="Upload PDF File" onclick="btn_pdf_upload_Click" />
                                            </td>
                                        </tr>
                                    </table>   
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:Button>
                                    <asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button>
                                </td>
                            </tr>
                        </table>
                        </FormTemplate>
                    </EditFormSettings>            
                    <PagerStyle Position="TopAndBottom" />
                </MasterTableView>
            </telerik:RadGrid>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>"
                               SelectCommand="SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]"></asp:SqlDataSource>
                     
            <br />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>"
                SelectCommand="SELECT * FROM [tbl_pdf_docs] ORDER BY [s_page]" DeleteCommand="DELETE FROM [tbl_pdf_docs] WHERE [id] = @id"
                InsertCommand="INSERT INTO [tbl_pdf_docs] ([s_page], [s_doc_title], [s_link_title], [s_doc_url], [d_date_uploaded], [d_date_displayed], [b_visible]) VALUES (@s_page, @s_doc_title, @s_link_title, @s_doc_url, @d_date_uploaded, @d_date_displayed, @b_visible)"
                 
                UpdateCommand="UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed, [b_visible] = @b_visible WHERE [id] = @id">
                <DeleteParameters>
                    <asp:Parameter Name="id" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="s_page" Type="String" />
                    <asp:Parameter Name="s_doc_title" Type="String" />
                    <asp:Parameter Name="s_doc_url" Type="String" />
                    <asp:Parameter Name="d_date_uploaded" Type="DateTime" />
                    <asp:Parameter Name="d_date_displayed" Type="DateTime" />
                    <asp:Parameter Name="b_visible" Type="Boolean" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="s_page" Type="String" />
                    <asp:Parameter Name="s_doc_title" Type="String" />
                    <asp:Parameter Name="s_doc_url" Type="String" />
                    <asp:Parameter Name="d_date_uploaded" Type="DateTime" />
                    <asp:Parameter Name="d_date_displayed" Type="DateTime" />
                    <asp:Parameter Name="b_visible" Type="Boolean" />
                    <asp:Parameter Name="id" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
             
        </td>
    </tr>
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="SqlDataSource1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="SqlDataSource1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
.cs
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.KeepInEditMode = true;
            e.ExceptionHandled = true;
            DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be updated. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " updated");
        }
    }
 
    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            e.KeepInInsertMode = true;
            DisplayMessage(true, "Title cannot be inserted. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(false, "Title inserted");
        }
    }
 
    protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be deleted. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " deleted");
        }
    }
 
    private void DisplayMessage(bool isError, string text)
    {
        Label label = (isError) ? this.Label1 : this.Label2;
        label.Text = text;
    }
 
    private static DataTable tblData = new DataTable();
 
    protected void Page_Load(object sender, System.EventArgs e)
    {
         
 
    }
 
    //protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    //{
 
    //    if (e.CommandName == "Update")
    //    {
    //        GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
    //        Label label = (Label)gridEditFormItem.FindControl("lbl_id");
    //        TextBox textboxPage = (TextBox)gridEditFormItem.FindControl("s_page");
    //        TextBox textboxDocTitle = (TextBox)gridEditFormItem.FindControl("s_doc_title");
    //        TextBox textboxLinkTitle = (TextBox)gridEditFormItem.FindControl("s_link_title");
    //        TextBox textboxDocUrl = (TextBox)gridEditFormItem.FindControl("s_doc_url");
    //        TextBox textboxDateUp = (TextBox)gridEditFormItem.FindControl("d_date_uploaded");
    //        TextBox textboxDateDisplay = (TextBox)gridEditFormItem.FindControl("d_date_displayed");
    //        SqlDataSource1.UpdateCommand = "UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed WHERE id= @lbl_id";
    //        SqlDataSource1.Update();
    //    }
 
    //    if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
    //    {
    //        GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
    //        editColumn.Visible = false;
 
    //        e.Canceled = true;
    //        e.Item.OwnerTableView.InsertItem();
 
    //        GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
    //        TextBox box = insertedItem.FindControl("txt_company_id") as TextBox;
    //        box.Text = Request.QueryString["id"].ToString();
 
 
    //    }
    //    else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted)
    //    {
    //        e.Canceled = true;
 
    //    }
    //    else
    //    {
    //        GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
    //        if (!editColumn.Visible)
    //            editColumn.Visible = true;
    //    }
    //}
     
    protected void btn_pdf_upload_Click(object sender, EventArgs e)
    {
         
        Response.Redirect("pdf_file_upload.aspx");
    }
 
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        //if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        //{
        //    GridEditFormItem editform = (GridEditFormItem)e.Item;
 
        //    RadComboBox ddl_menu_items = (RadComboBox)editform.FindControl("RadComboBox1");
 
        //    //Populate the dropdownlist
        //    SqlCommand cmd = new SqlCommand("SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]", new SqlConnection(ConfigurationManager.AppSettings["SugarSandsConnectionString"]));
        //    cmd.Connection.Open();
 
        //    SqlDataReader ddlValues;
        //    ddlValues = cmd.ExecuteReader();
 
        //    ddl_menu_items.DataSource = ddlValues;
        //    ddl_menu_items.DataValueField = "MenuId";
        //    ddl_menu_items.DataTextField = "MenuText";
        //    ddl_menu_items.DataBind();
 
        //    cmd.Connection.Close();
        //    cmd.Connection.Dispose();
        //}
    }

MV
Top achievements
Rank 1
 answered on 15 Apr 2016
3 answers
628 views
We recently upgraded from the ASP.NET Classic controls to the ASP.NET AJAX controls on one of our largest projects.  One of our requirements was to maintain current behavior and appearance on all controls.  Unfortuantely, we are having a fair amount of trouble with RadGrids. 

We are using a RadGrid with server side grouping and expand/collapse functionality enabled.  When a user expands/collapses an item, the ItemCommand event is fired which updates a session variable to keep track of which items are expanded.  When the user returns to the page, the ItemDataBound method determines whether or not to expand a GridGroupHeaderItem depending on the values stored in the session variable.  The good news is that expanded/collapsed states are rendering correctly on subsequent page loads.  Unfortunately, if the user then expands or collapses any item, all GridItems that were expanded in the ItemDataBound disappear.  The groups that these items belong to are still expanded and items that have been expanded after page load are not affected.  Clicking on the group again collapses the group with the missing items, and the next click re-expands it revealing the items that were missing.

Does anyone have any idea why our items are being hidden?  I included snippets from the aspx and aspx.cs files below.  Specific names and details have been changed to protect the innocent.

...
 
<telerik:RadAjaxManager runat="server" ID="radAjaxManager" EnableAJAX="true" OnAjaxRequest="RadAjaxManager_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="radAjaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="radGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
...
 
<telerik:RadGrid ID="radGrid1" runat="server" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true" AutoGenerateColumns="false" EnableEmbeddedSkins="false" GroupingEnabled="true"
    OnItemCommand="radGrid1_ItemCommand" OnItemDataBound="radGrid1_ItemDataBound" OnNeedDataSource="radGrid1_NeedDataSource"
    ShowGroupPanel="false" ShowHeader="true" Skin="XYZ">
    <ClientSettings AllowColumnsReorder="true" AllowGroupExpandCollapse="true" AllowDragToGroup="false" ReorderColumnsOnClient="true">
        <Resizing AllowColumnResize="false" AllowRowResize="false" EnableRealTimeResize="false" ResizeGridOnColumnResize="false"/>
        <ClientEvents OnGridCreated="radGrid1_GridCreated" />
    </ClientSettings>
    <MasterTableView AllowMultiColumnSorting="false" DataKeyNames="Data1, Data2"
        GroupLoadMode="Server" GroupsDefaultExpanded="false" ShowHeader="true" Name="mtvRadGrid1"
        NoDetailRecordsText="There are no items that match your request."
        NoMasterRecordsText="There are no items that match your request." ShowFooter="false">
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField Aggregate="First" FieldAlias="Group1NameAlias" FieldName="Group1Name"/>
                    <telerik:GridGroupByField Aggregate="First" FieldAlias="Group1IdAlias" FieldName="Group1Id"/>
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="Group1Name" SortOrder="Ascending" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField Aggregate="First" FieldAlias="Group2NameAlias" FieldName="Group2Name"/>
                    <telerik:GridGroupByField Aggregate="First" FieldAlias="Group2IdAlias" FieldName="Group2Id"/>
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="Group2Name" SortOrder="Ascending" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <Columns>
            <telerik:GridBoundColumn UniqueName="ColumnA" DataField="ColumnA" />
            <telerik:GridBoundColumn UniqueName="ColumnB" DataField="ColumnB" />
            ...
            <telerik:GridTemplateColumn UniqueName="link" HeaderText="Link" Groupable="false" SortExpression="sortExpression" HeaderStyle-HorizontalAlign="Left" >
                <ItemTemplate>
                    <asp:HyperLink ID="itemLink" runat="server"></asp:HyperLink>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
                ...
        </Columns>
    </MasterTableView>
</telerik:RadGrid>


protected void radGrid1_ItemDataBound(object source, GridItemEventArgs e)
{
    if (e.Item.ItemType == GridItemType.GroupHeader)
    {
        GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
        DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
 
        // Telerik does not allow public access to the GroupLevel property of GridItems.
        // Unfortunately, this is the only way we have found to determine the group level.
        // The GroupIndex is formatted as "Group1_Group2_Group3"
        string[] headerItemGroups = e.Item.GroupIndex.Split('_');
 
        string group1Name;
        string group2Name;
 
        int group1Id;
        int group2Id;
        int headerItemGroupLevel = headerItemGroups.Length - 1; // GroupLevel is 0 based
 
        if (headerItemGroupLevel == 0)
        {
            List<int> expandedGroup1IdList = GetSessionExpandedGroup1IdList();
 
            group1Name = groupDataRow["Group1Name"].ToString();
            group1Id = (int)groupDataRow["Group1Id"];
                 
            // Telerik does not allow access to DataKeyValues in the GridGroupHeaderItems hence the horrible code below.
            // We can add a group by field to the header, grab it on ItemDataBound, and then replace it with meaningful text
            item.DataCell.Text = "Group1: " + group1Name;
            item.Expanded = expandedGroup1IdList.Contains(group1Id);
        }
        else if (headerItemGroupLevel == 1)
        {
            List<int> expandedGroup2IdList = GetSessionExpandedGroup2IdList();
 
            group2Name = groupDataRow["Group2Name"].ToString();
            group2Id = (int)groupDataRow["Group2Id"];
 
            // Telerik does not allow access to DataKeyValues in the GridGroupHeaderItems hence the horrible code below.
            // We can add a group by field to the header, grab it on ItemDataBound, and then replace it with meaningful text
            item.DataCell.Text = "Group2: " + group2Name;
            item.Expanded = expandedGroup2IdList.Contains(group2Id);
        }
    }
    else if (e.Item.ItemType == GridItemType.Item)
    {
        Class1 dataItem= (Class1)e.Item.DataItem;
 
        HyperLink link = (HyperLink)e.Item.FindControl("itemLink");
 
        if (dataItem.property == ...)
        {
            link.NavigateUrl = ...
            link.Text = ...
        }
        else if (dataItem.property == ...)
        {
            link.NavigateUrl = ...
            link.Text = ...
        }
    }
}
 
protected void radGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        // Telerik does not allow public access to the GroupLevel property of GridItems.
        // Unfortunately, this is the only way we have found to determine the group level.
        // The GroupIndex is formatted as "Group1_Group2_Group3"
        string[] headerItemGroups = e.Item.GroupIndex.Split('_');
        string[] dataItemGroups;
 
        int group1Id;
        int group2Id;
        int headerItemGroupLevel = headerItemGroups.Length - 1; // Group Level is 0 based
 
        bool isExpanded = !e.Item.Expanded; // The item is currently expanding/collapsing so the state is yet to change
 
        foreach (GridDataItem item in e.Item.OwnerTableView.Items)
        {
            dataItemGroups = item.GroupIndex.Split('_');
 
            // Telerik does not provide access to DataKeyValues from GridGroupHeaderItems
            // Loop through all items in the MasterTableView until we find an item that belongs to the group(s) of the clicked item
            // Save the appropriate IDs in a session variable to track which items are expanded
            if (headerItemGroupLevel == 0 && headerItemGroups[0] == dataItemGroups[0])
            {
                group1Id = (int)item.GetDataKeyValue("Group1Id");
 
                SaveSessionExpandedGroup1IdList(group1Id, isExpanded);
 
                break;
            }
            else if (headerItemGroupLevel == 1 && headerItemGroups[0] == dataItemGroups[0] && headerItemGroups[1] == dataItemGroups[1])
            {
                group2Id = (int)item.GetDataKeyValue("group2Id");
 
                SaveSessionExpandedGroup2IdList(group2Id, isExpanded);
 
                break;
            }
        }
    }
}
Marin
Telerik team
 answered on 15 Apr 2016
3 answers
339 views
I am attempting to do something similar to this but slightly different. I am attempting to put a raddatepicker in a radgrid filter template with the textbox disabled so the user cannot enter a date and must use the datepicker button. Then I want to have an imagebutton next to the datepicker that will clear the filter. The datepicker works as expected and filters the radgrid appropriately but clicking the imagebutton does not clear the filter. Here is my code for the column including javascript:

<telerik:GridTemplateColumn DataField="openDate" DataType="System.DateTime" HeaderText="Open Date"
    SortExpression="openDate" UniqueName="openDate" ReadOnly="True" FilterControlAltText="Filter open date">
    <HeaderStyle Width="150px" />
    <FilterTemplate>
        <telerik:RadDatePicker ID="OpenedRadDatePicker" runat="server" ClientEvents-OnDateSelected="OpenDateSelected"
            DbSelectedDate='<%# SetOpenedDate(Container) %>' DateInput-DisplayDateFormat="yyyy/MM/dd"
            Culture="en-US">
            <Calendar ID="OpenedRadDatePickerCalendar" runat="server" UseColumnHeadersAsSelectors="False"
                UseRowHeadersAsSelectors="False" ViewSelectorText="x">
            </Calendar>
            <DateInput ID="OpenedRadDatePickerDateInput" runat="server" DateFormat="yyyy/MM/dd"
                DisplayDateFormat="yyyy/MM/dd" Enabled="false">
                <ClientEvents OnLoad="OnClientLoad" />
            </DateInput>
            <DatePopupButton HoverImageUrl="" ImageUrl="" />
            <ClientEvents OnDateSelected="OpenDateSelected" />
        </telerik:RadDatePicker>
        <asp:ImageButton ID="ClearOpenDateButton" runat="server" ImageUrl="images/cancel.gif"
            AlternateText="Show All" ToolTip="Clear Open Date Filter" Style="vertical-align: middle"
            Height="15px" Width="15px" OnClientClick="ClearDateSelected(); return true;" />
        <telerik:RadScriptBlock ID="OpenDateSelectedRadScriptBlock" runat="server">
            <script type="text/javascript">
                var datePicker;
                function OnClientLoad(sender, args) {
                    datePicker = sender;
                }
 
                function ClearDateSelected() {
                    datePicker.clear();
                }
 
                function OpenDateSelected(sender, args) {
                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                    var date = FormatSelectedDate(sender);
                    var nextDate = GetNextSelectedDate(sender);
                    if (date != "" && nextDate != "") {
                        tableView.filter("openDate", date + " " + nextDate, Telerik.Web.UI.GridFilterFunction.Between);
                    }
                    else {
                        tableView.filter("openDate", "", Telerik.Web.UI.GridFilterFunction.NoFilter);
                    }
                }
 
                function FormatSelectedDate(picker) {
                    var formattedDate = "";
                    var date = picker.get_selectedDate();
                    if (date != null) {
                        var dateInput = picker.get_dateInput();
                        formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, "M/d/yyyy");
                    }
 
                    return formattedDate;
                }
                function GetNextSelectedDate(picker) {
                    var formattedDate = "";
                    var date = picker.get_selectedDate();
 
                    if (date != null) {
                        date.setDate(date.getDate() + 1);
                        var dateInput = picker.get_dateInput();
                        formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, "M/d/yyyy");
                    }
 
                    return formattedDate;
                }
            </script>
        </telerik:RadScriptBlock>
    </FilterTemplate>
    <ItemTemplate>
        <asp:Label runat="server" ID="openDateLabel" Text='<%# Eval("openDate", "{0:yyyy/MM/dd}") %>'></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>
 
 
protected DateTime? SetOpenedDate(GridItem item)
{
    string openFilter = item.OwnerTableView.GetColumn("openDate").CurrentFilterValue;
    if (string.IsNullOrEmpty(openFilter))
    {
        return new DateTime?();
    }
    else
    {
        return DateTime.Parse(openFilter.Substring(0, openFilter.IndexOf(" ")));
    }
}

When I press the ClearOpenDateButton while the radgrid is filtered, I do get the partial page postback. The RadGrid_ItemCommand event is properly fired, the LinqDataSource Selecting and Selected events run correctly as well and in the Selected event, it does indeed indicate in the arguments that all rows are being returned from the datasource but the grid doesn't get updated. I'm thinking it's just an update problem but I'm not sure why it works fine with the raddatepicker but not the imagebutton.

Also when I press the ClearOpenDateButton, the datepicker does clear the selected date as expected.
Pavlina
Telerik team
 answered on 15 Apr 2016
2 answers
135 views

I've bumped up against an issue where in the basic rotator, my button on the right overlaps the content.  This happens only in Chrome, and it looks fine in all other browsers.  I haven't added any styling and I'm doing it on a blank test page.  So either the existing default styling is off, or there is some setting (like my widths?)  that I need to adjust.  Any help is appreciated.

 

 

<telerik:RadRotator RenderMode="Lightweight" ID="RadRotator1" OnItemDataBound="RadRotator1_ItemDataBound" runat="server" Width="930px" Height="200px"
                            RotatorType="Buttons"  ItemHeight="200" ItemWidth="896"   >
    <Items>
        <telerik:RadRotatorItem></telerik:RadRotatorItem>
    </Items>
     <ItemTemplate>
           test test test
    </ItemTemplate>
</telerik:RadRotator>

Vessy
Telerik team
 answered on 15 Apr 2016
1 answer
49 views

     <telerik:RadGrid ID="demo"
                        runat="server" PageSize="12" AllowPaging="true"
                        EnableEmbeddedSkins="false" AutoGenerateColumns="false" ShowHeader="true" ShowFooter="false"
                        AllowCustomPaging="false" PagerStyle-AlwaysVisible="true" >
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="False"/>   <telerik:RadGrid/>

when records are more then pagesize,and change page size which equals to records than not able to do change page size as its not visible . Can anyone help with this?

Eyup
Telerik team
 answered on 15 Apr 2016
1 answer
170 views

Hi,

I have to do add a class to all the combo box items which has checkbox in the page and do some other manipulation on it. So right now am doing on page load using the $('.RadComboBoxDropDown').find('label') this code. But this will not solve my issue completely since the combo items can change dynamically. So i thought of doing it on drop down open event. But I can't find how to register for this event in javascript ?

 

Thanks

Kumaran

Eyup
Telerik team
 answered on 15 Apr 2016
4 answers
314 views
Hi, All.

I want to merge some item in grid

Not Header But Item

Can I do this in grid?

Count Name
5 name1
name2
name3
name4
name5
4 name1
name2
name3
name4


God regards you
Eyup
Telerik team
 answered on 15 Apr 2016
6 answers
687 views

I have a question about the rows/columns. I am new to using this control. Shouldn't the columns wrap to the next row automatically at 12 columns?

For example:

I want something like the following in the medium layout. Currently the XL, LG, SM and XS look exactly the way I want them. It is just the medium that I have issues with.

Name: TEXTBOX

Allergies: TEXTBOX

 

Here is the code:

                                        <telerik:LayoutRow>
                                            <Columns>
                                                <telerik:LayoutColumn Span="1" SpanMd="2" SpanSm="12" SpanXs="12">
                                                    Name:
                                                </telerik:LayoutColumn>
                                                <telerik:LayoutColumn Span="4" SpanMd="10" SpanSm="12" SpanXs="12">
                                                    <asp:Textbox runat="server" ID="txtName" Width="90%" ReadOnly="true" />
                                                </telerik:LayoutColumn>
                                                <telerik:LayoutColumn Span="1" SpanMd="2" SpanSm="12" SpanXs="12">
                                                    Allergies:
                                                </telerik:LayoutColumn>
                                                <telerik:LayoutColumn Span="6" SpanMd="10" SpanSm="12" SpanXs="12">
                                                    <asp:TextBox runat="server" ID="txtAllergies" Width="90%" ReadOnly="true" />
                                                </telerik:LayoutColumn>
                                            </Columns>
                                        </telerik:LayoutRow>

 

I am getting something that looks like the following:

Name: TEXTBOX
           Allergies:

TEXTBOX

 

I just cannot figure out how to get those side by side in the XL & LG but on 2 separate rows in the MD. Thanks for any help!

DogBizPro
Top achievements
Rank 1
 answered on 15 Apr 2016
1 answer
175 views

Hi;

I have several pages that have a .NET UpdatePanel within which is a RadTabStrip controlling a .NET MultiView control via the OnTabClick event.  The behaviour we were seeing was that after clicking the RadTabStrip and having the MultiView change views, most controls on the page because unresponsive.  Clicking on a "blank" space within the page would then allow the controls to respond.  The most obvious case was a dropdownlist that, when clicked, would get focus but not actually drop down to display its items.  If we clicked on a non-control area of the screen then clicked back on the dropdownlist, it would then drop down and display its items.

I did a number of experiments, including changing the MultiView over to a Telerik MultiPage control.  If I did this and set the MultiPageID in the RadTabStrip and removed the firing of the OnTabClick event, the problem behaviour would not occur.  But we need the OnTabClick event to initialize controls within Views/Pages.

If I removed the top-level UpdatePanel containing the RadTabStrip and the MultiView, the problem would not occur.  However, then we would have an undesirable full postback.

If I put an UpdatePanel around the MultiView and set the RadTabStrip as an AsyncPostBackTrigger, the problem still occurred.  If I changed the trigger to a PostBackTrigger, the problem did not occur but again we'd have the undesirable postback page "flash".

I found that one page we had did not experience this issue.  The difference was that all controls on the page (except for a RadWindowManager, which was declared before the UpdatePanel on all pages concerned) were contained in the ContentTemplate of this "top-level" UpdatePanel.  The problem pages had divs containing controls and additional UpdatePanels declared after/outside of the first "top-level" UpdatePanel.

Moving these divs/controls/update panels inside the top-level update panel eliminated the error.  After clicking the RadTabStrip and having the MultiViewchange views, the page controls responded to input.  For example, the dropdownlist described above correctly dropped-down and displayed its items when clicked.

Any ideas what exactly is going on with this?  As far as I can tell, I'm able to move everything into the top-level update panel without breaking my pages, but I still don't know exactly WHY that solution works.  I can't easily post a code example since there's a lot going on in these pages.  If necessary I can try to create a sample project that reproduces the issue.

Veselin Tsvetanov
Telerik team
 answered on 15 Apr 2016
6 answers
268 views
I have the menu built into a header on my application.  I am using the new Glow skin and I would like to remove the border around the menu.  What style do I need to override to remove that border?
Clive Hoggar
Top achievements
Rank 1
 answered on 15 Apr 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?