<
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 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