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

How do I get RadUpload additional field value at clientside

3 Answers 130 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
kevin yang
Top achievements
Rank 1
kevin yang asked on 19 Jul 2010, 07:43 PM
                    <telerik:RadGrid ID="rgGrid" runat="server" AutoGenerateColumns="False" AllowAutomaticInserts="True"
                        AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" DataSourceID="ldsProfiles"
                        GridLines="None" Skin="Office2007" BorderWidth="0px" OnItemCommand="rgGrid_ItemCommand"
                        OnItemUpdated="rgGrid_ItemUpdated" OnItemInserted="rgGrid_ItemInserted" OnItemCreated="rgGrid_ItemCreated"  >
                        <MasterTableView DataKeyNames="ProposalAttachmentID" DataSourceID="ldsProfiles"
                            EditMode="EditForms" CommandItemDisplay="Top" >
                            <CommandItemStyle CssClass="gridHeader" />
                            <CommandItemTemplate>
                                <div class="gridHeader">
                                    Files
                                </div>
                                  
                                <div class="sectionHeaderButton" style="margin-left: 10px;">
                                    <asp:LinkButton ID="rgProAddButton" runat="server" Text="(add)" CommandName="InitInsert" Visible='<%# 
  
!rgGrid.MasterTableView.IsItemInserted   %>' />
                                </div>
                                   
                            </CommandItemTemplate>
                            <Columns>
                                <telerik:GridBoundColumn DataField="UploadDate" DataType="System.DateTime" HeaderText="Date"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="UploadDate"
                                    UniqueName="UploadDate" DataFormatString="{0:MM/dd/yyyy}" ItemStyle-Width="13%">
<ItemStyle Width="13%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="User.FullName" DataType="System.String" HeaderText="Author"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="User.FirstName"
                                    UniqueName="User.FullName" ItemStyle-Width="15%">
<ItemStyle Width="15%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn DataField="FileName" HeaderText="File" SortExpression="FileName"
                                    UniqueName="FileName" EditFormHeaderTextFormat="">
                                    <ItemTemplate>
                                                
                                        <asp:HyperLink ID="lbPorfiles" runat="server"  NavigateUrl='<%# UploadPath+"/"+Eval("ProposalFK")+"/"+ Eval("User.Login") 
  
+"/"+ Eval("FileName")%>' Target="_blank"  Text='<%# Bind("FileName")%>'></asp:HyperLink>
                                          
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div style="left">
                                            <telerik:RadUpload ID="rdProfile" runat="server" InitialFileInputsCount="1"  
                                                MaxFileInputsCount="5" Localization-Add="Add More Files" EnableFileInputSkinning="true"
                                                ControlObjectsVisibility="AddButton" MaxFileSize="1000000" OnClientFileSelected="ValidateExtension"   
                                                AllowedFileExtensions=".doc,.pdf,.ppt,.xls" OnClientAdded="addTitle" Skin="Office2007" 
                                                Width="95%" InputSize="35">  
                                                <Localization Add="Add More Files" />
                                            </telerik:RadUpload>
                                            <span id="fileExtentionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Invalid file 
  
extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls</span
                                            <span id="nullDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please enter 
  
Description</span
                                            <span id="overDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please limit 
  
Description to 150 characters or less</span>                                                                                         
                                            <asp:CustomValidator Text="" runat="server" ID="FileUploadValidator" OnServerValidate="FileUpload_ServerValidate" 
  
ClientValidationFunction="ValidateFileUpload" />
                                            <%--        *Invalid file extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls
                                            </asp:CustomValidator> --%>                                                                                   
                                            <script type="text/javascript">
                                                function ValidateFileUpload(source, arguments)
                                                {
                                                    var radGrid = $find('<%= rgGrid.ClientID %>');
  
                                                    var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
  
                                                    var fileInputs = radUpload.getFileInputs()
                                                    var isValid = true;
  
  
                                                    //var descValue = $get('<%= rgGrid.ClientID %>' + 'Title' + i).value
                                                    var descValue = $get(radUpload.getID() + 'Title' + i).value                                                    
                                                      
                                                    //alert(descValue)
                                                    for (var i = 0; i < fileInputs.length; i++)
                                                    {
  
                                                    }
  
                                                    arguments.IsValid = isValid;
                                                }
                                                  
                                                var i = 0
                                                  
                                                function addTitle(sender, args)
                                                {
                                                    var inputRow = args.get_row();
                                                    var fileInputSpan = inputRow.getElementsByTagName("span")[0];
  
                                                    var tAddField = sender.getID("Title");
  
                                                    $(".ruInputs li[class='']:last span").after($("<textarea rows=3 cols='50'/>").attr("id", tAddField).attr("name", 
  
tAddField)).after($("<label class='fileInputLabel'>Description : </label>").attr("for", tAddField)).before($("<label class='fileInputLabel'>  File : 
  
</label>").attr("for", fileInputSpan));                                         
                                                }
  
                                            </script>
                                                                                           
                                        </div>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                        </MasterTableView>
                    </telerik:RadGrid>
I have a RadUpload control in EditTemplate inside a RadGrid.
I add the client code to add addtional field with TextArea type allowing user to enter comment for the uploading file.
And that additional comment field is a required field, also only 500 characters max limited.
I want a TextArea type because I want to user to see all the text they enter and input type=text just won't do the justification.
I seem to have a problem to get the addional field's value at client side code. 

I use  
   var radGrid = $find('<%= rgGrid.ClientID %>');

to get the grid control
and  
   var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
to get the upload control

When I try to retrive the value of the additional field by code similar to
   var descValue = $get(radUpload.getID() + 'Title' + i).value 
I am getting javascript error saying "object needed"

Anyone can help?
I attached my code

3 Answers, 1 is accepted

Sort by
0
kevin yang
Top achievements
Rank 1
answered on 20 Jul 2010, 11:08 PM
Any help from Telerik Support Team?
Thanks
0
Accepted
Yana
Telerik team
answered on 21 Jul 2010, 03:08 PM
Hello Kevin,

Actually the correct client method to get the id is get_id(), not getID(), please replace it like this:

var descValue = $get(radUpload.get_id() + 'Title' + i).value


Greetings,
Yana
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
0
kevin yang
Top achievements
Rank 1
answered on 21 Jul 2010, 08:27 PM
Yes, that solves the problem, thanks
Tags
Upload (Obsolete)
Asked by
kevin yang
Top achievements
Rank 1
Answers by
kevin yang
Top achievements
Rank 1
Yana
Telerik team
Share this question
or