如何向RadExplorer添加自定义列我向RadExplorer添加了两列日期和所有者。演示网址。
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/customgridcolumns/defaultcs.aspx
上一篇文章,当我添加两个coloumn标题时,我正在获取文件名和大小
private void AddGridColumn(string name, string uniqueName, bool sortable) { RemoveGridColumn(uniqueName); // Add a new column with the specified name GridTemplateColumn gridTemplateColumn1 = new GridTemplateColumn(); gridTemplateColumn1.HeaderText = name; if (sortable) gridTemplateColumn1.SortExpression = uniqueName; gridTemplateColumn1.UniqueName = uniqueName; gridTemplateColumn1.DataField = uniqueName; Aspx_RadFileExplorer.Grid.Columns.Add(gridTemplateColumn1); }
Function For ResolveRootDirectoryAsTree
<pre>
public override DirectoryItem ResolveRootDirectoryAsTree ( string xszPath )
{
PathPermissions zPathPermission = FullPermissions;
if ( xszPath.Equals ( "Document/Private" ) )
zPathPermission = PathPermissions.Read;
else if ( xszPath.Equals ( "Document/Public" ) )
zPathPermission = PathPermissions.Read | PathPermissions.Upload;
return new DirectoryItem(GetName(xszPath), GetDirectoryPath(xszPath), xszPath, GetDate(xszPath), zPathPermission, GetChildFiles(xszPath), GetChildDirectories(xszPath));
}
</pre>
ResolveDirectory的功能
public override DirectoryItem ResolveDirectory(string xszPath ) { PathPermissions zPathPermission = FullPermissions; if ( xszPath.Equals ( "Document/Private" ) ) zPathPermission = PathPermissions.Read; else if ( xszPath.Equals ( "Document/Public" ) ) zPathPermission = PathPermissions.Read | PathPermissions.Upload;DirectoryItem[] zdlDirectories = GetChildDirectories ( xszPath ); return new DirectoryItem ( GetName ( xszPath ), EndWithSlash ( GetDirectoryPath ( xszPath ) ), string.Empty, string.Empty, zPathPermission, GetChildFiles ( xszPath ), zdlDirectories ); } private string GetName ( string xszPath ) { if ( xszPath == null ) { return string.Empty; } return xszPath.Substring ( xszPath.LastIndexOf ( '/' ) + 1 ); }
在此函数中,我将获取OwnerID和Date作为字符串LoadDocuments()。如何将所有者ID显示为所有者自定义字段和日期到日期字段
{{1}}
答案 0 :(得分:0)
以下是文档的a link,以下是代码。
// Add a new 'custom column for the file owner'
GridTemplateColumn gridTemplateColumn2 = new GridTemplateColumn();
gridTemplateColumn2.HeaderText = "Owner Name";
gridTemplateColumn2.SortExpression = "Owner";
gridTemplateColumn2.UniqueName = "Owner";
gridTemplateColumn2.DataField = "Owner";
RadFileExplorer1.Grid.Columns.Add(gridTemplateColumn2);// Add the second column
//And the code for adding value for the file entry for the custom column.
public override DirectoryItem ResolveDirectory(string path)
{
// Update all file items with the additional information (date, owner)
DirectoryItem oldItem = base.ResolveDirectory(path);
foreach (FileItem fileItem in oldItem.Files)
{
// Get the information from the physical file
FileInfo fInfo = new FileInfo(Context.Server.MapPath(VirtualPathUtility.AppendTrailingSlash(oldItem.Path) + fileItem.Name));
// Add the information to the attributes collection of the item. It will be automatically picked up by the FileExplorer
// If the name attribute matches the unique name of a grid column
fileItem.Attributes.Add("Date", fInfo.CreationTime.ToString());
// Type targetType = typeof(System.Security.Principal.NTAccount);
// string value = fInfo.GetAccessControl().GetOwner(targetType).Value.Replace("\\", "\\\\");
string ownerName = "Telerik";
fileItem.Attributes.Add("Owner", ownerName);
}
return oldItem;
}
希望这会对你有所帮助。