RadFileExplorer in Grid Edit Form

6 posts, 0 answers
  1. Johnny
    Johnny avatar
    8 posts
    Member since:
    Dec 2006

    Posted 05 Jan 2010 Link to this post

    If i want to use the radfileexplorer in a grid edit form i get an error trying to find the fileName text box.  can you help me fix this line of code to get find this control.

    function

     

    OnFileSelected(wnd, fileSelected) {

     

     

    var textbox = $get('<%= Master.Master.FindControl("ContentPlaceHolder1").FindControl("ContentPlaceHolder2").FindControl("RadGrid2").GridEditableItem.Controls["fileName"].ClientID %>');

     

    textbox.value = fileSelected;

    I have tried many ways and cannot figure this out. Thanks!

  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 08 Jan 2010 Link to this post

    Hi Johnny,

    Unfortunately, the provided information is not enough for me to determine the exact reason for the problem. Could you please open a new support ticket and send me a runnable project that shows the configuration of the controls on the pages? I will check it, do my best to implement the desired behavior in the project and send it back.

    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Johnny
    Johnny avatar
    8 posts
    Member since:
    Dec 2006

    Posted 25 Jan 2010 Link to this post

    I thought i posted a reply but i dont see it in here. Basically i need an example in c# of how to put a RadFileExplorer in a RadGrid Edit Form template.  Can you tell me how to do that?  Basically i cannot get the file name to populate the form field in the edit form.  Please Help.
  4. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 28 Jan 2010 Link to this post

    Hi Johnny,

    Your scenario is a bit complex and I need to examine your exact code in order to provide a working solution. Could you please open a new support ticket and send me a runnable project that shows your exact setup? I will check it and do my best to rework and send it back as soon as possible.

    I am looking forward to hearing from you.

    Regards,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Johnny
    Johnny avatar
    8 posts
    Member since:
    Dec 2006

    Posted 11 Feb 2010 Link to this post

    Here is my code. Basically i want a file select dialog box in the editformtemplate.  The client side code looking to update the filename textfield is causing me issues.  It cant find the control...i dont see any reference to findcontrol within an editform template from client site...only on update.



    <%

    @ Page Language="C#" AutoEventWireup="true" CodeFile="gridtest.aspx.cs" Inherits="gridtest" %>

     

    <%

    @ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

     

    <!

     

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <

     

    html xmlns="http://www.w3.org/1999/xhtml">

     

    <

     

    head runat="server">

     

     

    <title></title>

     

    </

     

    head>

     

    <

     

    body>

     

     

    <form id="form1" runat="server">

     

     

    <telerik:RadScriptManager ID="ScriptManager" runat="server" />

     

     

    <div>

     

     

     

    <asp:Label ID="Label3" runat="server" EnableViewState="False" Font-Bold="true" ForeColor="#FF8080"></asp:Label>

     

     

    <asp:Label ID="Label4" runat="server" EnableViewState="False" Font-Bold="true" ForeColor="#00C000"></asp:Label>

     

     

    <telerik:RadGrid ID="RadGrid2" runat="server" Skin="Telerik" GridLines="None"

     

     

    AllowPaging="true" PageSize="20" AllowSorting="true" Width="100%" AutoGenerateColumns="False" ShowStatusBar="true" AllowAutomaticDeletes="true" AllowAutomaticInserts="true"

     

     

    AllowAutomaticUpdates="true" DataSourceID="SqlDataSource5" HorizontalAlign="NotSet"

     

     

    OnItemDeleted="RadGrid2_ItemDeleted" OnItemInserted="RadGrid2_ItemInserted" OnItemUpdated="RadGrid2_ItemUpdated">

     

     

    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>

     

     

    <MasterTableView Name="Master" NoMasterRecordsText="No Categories to Display" NoDetailRecordsText="No Categories To Display"

     

     

    CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add New Category"

     

     

    CommandItemSettings-RefreshText="refresh" GridLines="None" DataKeyNames="categoryGuid"

     

     

    AllowFilteringByColumn="false">

     

     

    <Columns>

     

     

    <telerik:GridEditCommandColumn HeaderStyle-Width="40px"

     

     

    FilterControlWidth="30px" ButtonType="ImageButton" UniqueName="EditCommandColumn">

     

     

    <ItemStyle CssClass="MyImageButton" />

     

     

    </telerik:GridEditCommandColumn>

     

     

    <telerik:GridBoundColumn UniqueName="categoryName" HeaderText="Video Category Name"

     

     

    DataField="categoryName">

     

     

    </telerik:GridBoundColumn>

     

     

    <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"

     

     

    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"

     

     

    UniqueName="DeleteColumn">

     

     

    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />

     

     

    </telerik:GridButtonColumn>

     

     

    </Columns>

     

     

    <EditFormSettings EditFormType="Template">

     

     

    <FormTemplate>

     

     

    <table id="Table3" cellspacing="2" cellpadding="1" border="0" rules="none" style="border-collapse: collapse">

     

     

    <tr class="EditFormHeader">

     

     

    <td>

     

     

    <b>Category/Album</b></td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td>

     

    Category/Album Name:

     

    <asp:RequiredFieldValidator ControlToValidate="TextBoxTitle2" ID="RequiredFieldValidator5"

     

     

    runat="server" ErrorMessage="Required" ValidationGroup="vg3"></asp:RequiredFieldValidator></td>

     

     

    <td>

     

     

    <asp:TextBox ID="TextBoxTitle2" runat="server" Columns="50" Text='<%# Bind( "categoryName") %>'>

     

     

    </asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td>

     

    Category/Album Image Art:

    </td>

     

     

    <td>

     

     

     

    <div>

     

    Select a file:

     

    <asp:TextBox ID="fileName" runat="server" Width="350px"></asp:TextBox>

     

    <

     

    asp:Button ID="selectFile" OnClientClick="OpenFileExplorerDialog(); return false;"

     

    Text

     

    ="Open... " runat="server" />Text="Open... " runat="server" />Text="Open... " runat="server" />Text="Open... " runat="server" />

     

     

    <br />

     

     

    <br />

     

    Open the dialog and double click on a file to select it.

     

    </div>

     

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    <table width="100%">

     

     

    <tr>

     

     

    <td align="right">

     

     

    <asp:ImageButton ID="btnUpdate" alt="Update" ImageUrl="/images/Update.gif"

     

     

    runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>

     

     

    </asp:ImageButton>

     

     

    &nbsp;<asp:ImageButton alt="Cancel" ID="btnCancel" ImageUrl="/images/Cancel.gif"

     

     

    runat="server" CausesValidation="False" CommandName="Cancel"></asp:ImageButton>

     

     

    </td>

     

     

    </tr>

     

    </

     

    table>

     

     

    </FormTemplate>

     

     

    </EditFormSettings>

     

     

    </MasterTableView>

     

     

    </telerik:RadGrid>

     

     

    <asp:SqlDataSource ID="SqlDataSource5" runat="server" SelectCommandType="StoredProcedure"

     

     

    SelectCommand="sp_GetMinistryAudioCategories" UpdateCommandType="StoredProcedure"

     

     

    UpdateCommand="sp_UpdateMinistryAudioCategory" DeleteCommandType="StoredProcedure"

     

     

    DeleteCommand="sp_RemoveMinistryAudioCategory" InsertCommandType="StoredProcedure"

     

     

    InsertCommand="sp_InsertMinistryAudioCategory">

     

     

    <InsertParameters>

     

     

    <asp:Parameter Name="categoryName" Type="String" />

     

     

    </InsertParameters>

     

     

    <UpdateParameters>

     

     

    <asp:Parameter Name="categoryGuid" />

     

     

    <asp:Parameter Name="categoryName" Type="String" />

     

     

    <asp:Parameter Name="groupGuid" />

     

     

    </UpdateParameters>

     

     

    <DeleteParameters>

     

     

    <asp:Parameter Name="categoryGuid" />

     

     

    </DeleteParameters>

     

     

    </asp:SqlDataSource>

     

     

     

     

    <script type="text/javascript">

     

     

    function OpenFileExplorerDialog() {

     

     

    var wnd = $find("<%= ExplorerWindow.ClientID %>");

     

    wnd.show();

    }

     

    //This function is called from the Explorer.aspx page

     

     

    function OnFileSelected(wnd, fileSelected) {

     

     

    var textbox = $get("<%= RadGrid2.MasterlfileName.ClientID %>");

     

    textbox.value = fileSelected;

    }

     

    </script>

     

     

    <telerik:RadWindow runat="server" Width="550px" Height="560px" VisibleStatusbar="false"

     

     

    NavigateUrl="Explorer.aspx" ID="ExplorerWindow" Modal="true" Behaviors="Close,Move">

     

     

    </telerik:RadWindow>

     

     

    </div>

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>




     

    using

     

    System;

     

    using

     

    System.Collections.Generic;

     

    using

     

    System.Linq;

     

    using

     

    System.Web;

     

    using

     

    System.Web.UI;

     

    using

     

    System.Web.UI.WebControls;

     

    using

     

    System.Data.SqlClient;

     

    using

     

    System.Data;

     

    using

     

    Telerik.Web.UI;

     

    public

     

    partial class gridtest : System.Web.UI.Page

     

    {

     

    private string conn

     

    {

     

    get { return (String)ViewState["conn"]; }

     

     

    set { ViewState["conn"] = value; }

     

    }

     

    private Guid ministryGuid

     

    {

     

    get { return (Guid)ViewState["ministryGuid"]; }

     

     

    set { ViewState["ministryGuid"] = value; }

     

    }

     

    private Guid userGuid

     

    {

     

    get { return (Guid)ViewState["userGuid"]; }

     

     

    set { ViewState["userGuid"] = value; }

     

    }

     

    private string ministryName

     

    {

     

    get { return (String)ViewState["ministryName"]; }

     

     

    set { ViewState["ministryName"] = value; }

     

    }

     

    private string ministryDomain

     

    {

     

    get { return (String)ViewState["ministryDomain"]; }

     

     

    set { ViewState["ministryDomain"] = value; }

     

    }

     

    private bool isAdmin

     

    {

     

    get { return (Boolean)ViewState["isAdmin"]; }

     

     

    set { ViewState["isAdmin"] = value; }

     

    }

     

    protected void Page_Load(object sender, EventArgs e)

     

    {

    conn = System.Configuration.

    ConfigurationManager.AppSettings["conn"];

     

    ministryGuid =

    new FaithNetworkContentManager().loggedInMinistryGuid;

     

    userGuid =

    new FaithNetworkContentManager().loggedInUserGuid;

     

    ministryName =

    new FaithNetworkContentManager().loggedInMinistryName;

     

    ministryDomain =

    new FaithNetworkContentManager().loggedInMinistryDomain;

     

    SqlDataSource5.ConnectionString = conn;

    SqlDataSource5.SelectParameters.Clear();

    SqlDataSource5.UpdateParameters.Clear();

    SqlDataSource5.InsertParameters.Clear();

    SqlDataSource5.DeleteParameters.Clear();

    SqlDataSource5.SelectParameters.Add(

    "ministryGuid", ministryGuid.ToString());

     

    SqlDataSource5.DeleteParameters.Add(

    "ministryGuid", ministryGuid.ToString());

     

    SqlDataSource5.InsertParameters.Add(

    "ministryGuid", ministryGuid.ToString());

     

    SqlDataSource5.UpdateParameters.Add(

    "ministryGuid", ministryGuid.ToString());

     

    }

     

     

    protected void RadGrid2_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)

     

    {

     

    if (e.Exception != null)

     

    {

    e.KeepInEditMode =

    true;

     

    e.ExceptionHandled =

    true;

     

    DisplayMessage2(

    true, "Category cannot be updated. Reason: " + e.Exception.Message);

     

    }

     

    else

     

    {

    DisplayMessage2(

    false, "Category updated");

     

    }

    }

     

    private void DisplayMessage2(bool isError, string text)

     

    {

     

    Label label = (isError) ? this.Label3 : this.Label4;

     

    label.Text = text;

    }

     

    protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)

     

    {

     

    if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked

     

    {

     

    GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid2.MasterTableView.GetColumn("EditCommandColumn");

     

    editColumn.Visible =

    false;

     

    }

     

    else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted)

     

    {

    e.Canceled =

    true;

     

    }

     

    else

     

    {

     

    GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid2.MasterTableView.GetColumn("EditCommandColumn");

     

     

    if (!editColumn.Visible)

     

    editColumn.Visible =

    true;

     

    }

    }

     

    protected void RadGrid2_PreRender(object sender, EventArgs e)

     

    {

     

    if (!Page.IsPostBack)

     

    {

    RadGrid2.EditIndexes.Add(0);

    RadGrid2.Rebind();

    }

    }

     

    protected void RadGrid2_ItemDeleted(object source, GridDeletedEventArgs e)

     

    {

     

    if (e.Exception != null)

     

    {

    e.ExceptionHandled =

    true;

     

    DisplayMessage2(

    true, "Category cannot be deleted. Reason: " + e.Exception.Message);

     

    }

     

    else

     

    {

    DisplayMessage2(

    false, "Category deleted");

     

    }

    }

     

    protected void RadGrid2_ItemInserted(object source, GridInsertedEventArgs e)

     

    {

     

    if (e.Exception != null)

     

    {

    e.ExceptionHandled =

    true;

     

    e.KeepInInsertMode =

    true;

     

    DisplayMessage2(

    true, "Category cannot be inserted. Reason: " + e.Exception.Message);

     

    }

     

    else

     

    {

    DisplayMessage2(

    false, "Category inserted");

     

    }

    }

     

    }

  6. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 17 Feb 2010 Link to this post

    Hello Johnny,

    In your case I recommend you to use this easy to be implemented solution inside the edit template:
    ................
    <
    td>
        <div>
            <script type="text/javascript">
                var txtID = null;
                function OpenFileExplorerDialog(sender, args)
                {
                    txtID = sender.id.replace("selectFile", "fileName");
                    var wnd = $find("<%= ExplorerWindow.ClientID %>");
                    wnd.show();
                }
                //This function is called from the Explorer.aspx page
                function OnFileSelected(wnd, fileSelected)
                {
                    // Test:
                    // Tova mi triabva              
                    var textbox = $get(txtID);
                    textbox.value = fileSelected;
                }
            </script>
            Select a file:
            <asp:TextBox ID="fileName" runat="server" Width="350px"></asp:TextBox>
            <asp:Button ID="selectFile" OnClientClick="OpenFileExplorerDialog(this); return false;"
                Text="Open... " runat="server" />
            <br />
            <br />
            Open the dialog and double click on a file to select it.
        </div>
    </td>
    ....................

    I hope this helps.

    All the best,
    Fiko
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top