Telerik Forums
UI for ASP.NET AJAX Forum
10 answers
351 views
Hello ,

       I am trying to paste an html in radeditor using

<script type="text/javascript">  
     var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object  
     editor.set_html('test');  
</script>

but when i try to find the editor using $find it gives error $find is not defined. plz help.

Regards
maggi

Marin Bratanov
Telerik team
 answered on 18 Apr 2016
1 answer
85 views

Good morning Telerik Team,

In our application, we disabled Telerik stylesheet CDN and enabled stylesheet combined in the stylesmanager. When we open a page with RadMenu control, the menu mess up and we found one webresource throw 500 error. Is there any setting we need set?

 

/Telerik.Web.UI.WebResource.axd?d=C6CXK_NKqeRQozdHamsVHY4iEh2-WHZ0hR2lZ4lb0QXhxNgPaCKJi-mbpKFkZJFyaLS96jrWiH-vS8d1mRcnCLyJDy45wzq4xT8qZIVpH1iN6XQB3Ms8R0ovsOLLDEf275IHDg2&t=635025536200000000&compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2015.3.930.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af59d7c8d-045a-4b22-9f9c-e124aae8c608%3a92753c09%3a91f742eb%3aed2942d4%3a8cee9284%3aed057d30%3aa3b7d93f%3a1f65231b%3a7f7626a2%3a9e1572d6%3ae25b4b77%3a45085116

 

 

Thanks in advance,

Lan

 

Plamen
Telerik team
 answered on 18 Apr 2016
2 answers
175 views
Code FileExplorer.InitialPath = "~/Documents";  or on any folder throws message box "Invalid characters in folder name."
This bug was introduced in Telerik.Web.UI_2010_2_826 and later. All previous releases until Telerik.Web.UI_2010_2_817_hotfix.zip was all right in such a functionality.
Check it, please.

Resolution has been found. Thanks.

How to delete this post?
Ashwin Shriwas
Top achievements
Rank 1
 answered on 18 Apr 2016
6 answers
262 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
536 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
259 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
89 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
32 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
101 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
259 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?