This is a migrated thread and some comments may be shown as answers.

How to find RadAsyncUpload ID inside the radgrid using java script

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 24 Oct 2012, 11:03 PM
<telerik:GridTemplateColumn DataField="Data" HeaderText="Imagen" UniqueName="Upload">
                                               <ItemTemplate>
                                                   <a class="FotoGrid" href="#" onclick="VerImagen($(this))">
                                                       <telerik:RadBinaryImage ID="RadBinaryImage2" runat="server" AlternateText='<%#Eval("Contenido", "Photo of {0}") %>'
                                                           AutoAdjustImageControlSize="false" DataValue='<%#Eval("Contenido") is DBNull ? null : Eval("Contenido")%>'
                                                           Height="80px" ToolTip='<%#Eval("Contenido", "Photo of {0}") %>' Width="80px" />
                                                   </a>
                                               </ItemTemplate>
                                               <EditItemTemplate>
                                                   <telerik:RadAsyncUpload ID="FotoActualizar" runat="server" AllowedFileExtensions="jpg,jpeg,pdf"
                                                       MaxFileInputsCount="1" MaxFileSize="1048576" ToolTip="Actualizar Archivo">
                                                       <Localization Cancel="Cancelar" Remove="Quitar" Select="Archivo" />
                                                   </telerik:RadAsyncUpload>
                                                   <asp:CustomValidator runat="server" ID="cvUploadFotoMaterial" ClientValidationFunction="validateUploadFoto"
                                                       ErrorMessage="Fotografia es requerido" ForeColor="Red" ValidationGroup="vgGridFotos">*</asp:CustomValidator>
                                               </EditItemTemplate>
                                           </telerik:GridTemplateColumn>

var masterTable = $find("<%=gridFotos.ClientID %>").get_masterTableView();
                var upload = masterTable.get_dataItems()[0].findControl('FotoActualizar');

doesn't' work

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Oct 2012, 05:04 AM
Hi,

Try the following code to access the controls in edititemtemplate from client side.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
   GridEditableItem item = (GridEditableItem)e.Item;
   RadAsyncUpload upload = (RadAsyncUpload)item.FindControl("upload");
   RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['upload'] = '" + upload.ClientID + "';</script>"));
 }
}
JS:
function OnClientClick()
{
  var upload = $find(window['upload']);
}

Thanks,
Shinu.
Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or