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

I cannot seem to use jQuery to select a CheckBoxList inside a RadWindow ContentTemplate.Clicking on the checkboxes does nothing, but if I move the CheckBoxList out of the RadWindow it works fine. I've probably tried a dozen selectors, none work.

<telerik:RadWindow ID="MonthsWindow" runat="server" Skin="Metro" AutoSize="true" MinWidth="575px" MaxWidth="700px" MaxHeight="600px" KeepInScreenBounds="true" Left="100" Top="100" VisibleOnPageLoad="false" Behaviors="Close, Move" RenderMode="auto" DestroyOnClose="true" EnableAjaxSkinRendering="true" ShowContentDuringLoad="true">
<ContentTemplate>
<asp:CheckBoxList ID="CheckBoxList1" runat="Server">
     <asp:ListItem Text="Red" Value="red"></asp:ListItem>
     <asp:ListItem Text="Blue" Value="blue"></asp:ListItem>
     <asp:ListItem Text="Green" Value="green"></asp:ListItem>
</asp:CheckBoxList>
                                     
</ContentTemplate>
</telerik:RadWindow>

$("[id*='CheckBoxList1']").click(function () {
    //code
});
Marin Bratanov
Telerik team
 answered on 18 Apr 2016
5 answers
846 views
Hi everyone,

I need your help.
I added Telerik to a old project. radGrid works good, and i can open radWindow.
I have followed this demo http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

But for now, i can't close the radWindow, the reason : window.radWindow and window.frameElement.radWindow from GetRadWindow() script function are undefined.

If someone can help me.

My code :
default.aspx
<telerik:RadScriptManager runat="server" EnableViewState="false" ID="RadScriptManager1" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
             
            function ShowEditForm(id, rowIndex) {
                var anneeID = 0;
                var typeRessID = 0;
                var grid = $find("<%= RadGrid1.ClientID %>");
                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
 
                anneeID = document.getElementById("<%= cboAnnees.ClientID %>").value;
                if (document.getElementById("rbResident").checked == true) {
                    typeRessID = 1;
                }
                if (document.getElementById("rbExterne").checked == true) {
                    typeRessID = 2;
                }
                if (document.getElementById("rbAutre").checked == true) {
                    typeRessID = 3;
                }
                 
                grid.get_masterTableView().selectItem(rowControl, true);
 
                window.radopen("UpdateInfo.aspx?ID=" + id + "&TYPERESSID=" + typeRessID + "&ANNEEID=" + anneeID, "UserListDialog");
                return false;
            }
             
            function ShowInsertForm() {
                window.radopen("UpdateRessourceFrameset.aspx", "UserListDialog");
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
            
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

<telerik:RadGrid OnItemCreated="RadGrid1_ItemCreated" ID="RadGrid1" runat="server"
        AllowPaging="True" EnableViewState="true" Width="97%">
        <PagerStyle Mode="NumericPages"></PagerStyle>
        <MasterTableView pagesEnableViewState="true" AutoGenerateColumns="False" DataKeyNames="RESS_ID" ShowHeadersWhenNoRecords="false" ClientDataKeyNames="RESS_ID"
            Width="100%" PageSize="20">
            <Columns>
                <telerik:GridBoundColumn DataField="INFO2" HeaderText="Year" ReadOnly="True">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="INFO1" HeaderText="Name"/>
                 
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                         
                        <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <CommandItemTemplate>
                <a href="#" onclick="return ShowInsertForm();">No records...</a>
            </CommandItemTemplate>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="false"></Selecting>
             
        </ClientSettings>
    </telerik:RadGrid>
             
            <telerik:RadWindowManager ID="RadWindowManager1" EnableViewState="False" runat="server">
        <Windows>
            <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editer une ressource" Height="500px"
                Width="930px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                Modal="true">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

default.aspx.vb
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
       If e.Argument = "Rebind" Then
           RadGrid1.MasterTableView.SortExpressions.Clear()
           RadGrid1.MasterTableView.GroupByExpressions.Clear()
           RadGrid1.Rebind()
       ElseIf e.Argument = "RebindAndNavigate" Then
           RadGrid1.MasterTableView.SortExpressions.Clear()
           RadGrid1.MasterTableView.GroupByExpressions.Clear()
           RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
           RadGrid1.Rebind()
       End If
   End Sub
 
   Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
       If TypeOf e.Item Is GridDataItem Then
           Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink)
           editLink.Attributes("href") = "#"
           editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("RESS_ID"), e.Item.ItemIndex)
       End If
   End Sub

Updateinfo.aspx
<script type="text/javascript">
     function CloseAndRebind(args) {
         GetRadWindow().BrowserWindow.refreshGrid(args);
         GetRadWindow().close();
     }
 
     function GetRadWindow() {
        var oWindow = null;
         if (window.radWindow) oWindow = window.radWindow;
         else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
 
         return oWindow;
     }
 
     function CancelEdit() {
         window.UserListDialog.close();
     }
        </script>
 
 
....
 
<asp:ScriptManager id="smUpdateRess" runat="server" />
 
<asp:DetailsView runat="server" ID="DetailsView1" OnItemUpdating="DetailsView1_ItemUpdating" AutoGenerateEditButton="false" AutoGenerateRows="false" GridLines="None">
        
  
       <Fields>
            
             
           <asp:TemplateField>
               
               <EditItemTemplate>
                   <asp:Button ID="btAddContact" runat="server" Text="Save Contact" CommandName="Update" />
                    
                   <table border =0 style="width:750px">
                        <tr>
                            <td  style="height: 31px" colspan=4>
                           <asp:Label id="lblInfo1" runat="server" Text="Year: "></asp:Label>                            
                           <asp:TextBox id="txtInfo2" runat="server" Width="70px"  ReadOnly="true"  BackColor="LightGray" Text='<%# Container.DataItem("Info2") %>'></asp:TextBox>     
                             <asp:Label id="lblinfo2" runat="server" Text="Name:"></asp:Label>
                            <asp:TextBox ID="txtInfo1" runat="server" Width="70px"  ReadOnly="true"  BackColor="LightGray" Text='<%# Container.DataItem("INFO1") %>'></asp:TextBox>                    
                             
                            </td>            
                        </tr>
                         
                   </table>
               </EditItemTemplate>
           </asp:TemplateField>
            
       </Fields>
   </asp:DetailsView>

updateinfo.aspx.vb

on button click
 
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True)

But like i said, i get error of null with window.radWindow orwindow.frameElement.radWindow

thanks for your help.
Marin Bratanov
Telerik team
 answered on 18 Apr 2016
10 answers
393 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
111 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
207 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
293 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
590 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
319 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
120 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
44 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?