Specifying Icon using Custom Content Provider

3 posts, 0 answers
  1. Joel Kraft
    Joel Kraft avatar
    92 posts
    Member since:
    Jan 2004

    Posted 09 Dec 2010 Link to this post

    I have written a custom content provider for RadFileExplorer, and have been pretty happy with the results, with one little caveat, and that is the ability to specify an icon for the files.

    I create my FileItems, and everything is working fine, except for the icon. I am essentially doing this:

    new FileItem(
        "123456789",                  // name
        ".aspx",                      // extension
        0,                            // size
        "123/456/789",                // path
        "Handler.aspx?sid=123456789", // url

    It seems to me that specifying the extension field of the FileInfo object should be sufficient to decide what icon is displayed if it is has been specified, and the control can look elsewhere if it is not.  I am using the same semantics as Path.GetFileExension() used in the samples.  If this isn't used to specify the icon, what in the heck is it used for?

    The only way I can get the icon to appear is to put the file extension at the end of the name.  I do not want the file extension to appear as part of the the file name.  This seems like very odd behavior given that the extension is specified explicitly.  Is this a bug?
  2. Dobromir
    Dobromir avatar
    1633 posts

    Posted 13 Dec 2010 Link to this post

    Hi Joel,

    No, this is not a bug its the expected behavior of RadFileExplorer. At present, the filetype icon is based on a Css classes applied to the div element holding it icon. These classes are applied based on the filename of the populated item. However, you can modify this behavior during the ClientLoad event of RadFileExplorer, e.g.:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="OnClientLoad">
        <Configuration ViewPaths="~/ROOT" UploadPaths="~/ROOT" DeletePaths="~/ROOT" />
    <script type="text/javascript">
        function OnClientLoad(sender, args)
            var grid = sender.get_grid();//get reference to the grid
            var gridDataItems = grid.get_masterTableView().get_dataItems();//get reference to the grid's dataItems array
            for (var i = 0; i < gridDataItems.length; i++)
                var dataItem = gridDataItems[i].get_dataItem();//get reference to the dataItem
                var htmlElem = gridDataItems[i].get_element();//get dataItem html element
                var divElem = htmlElem.getElementsByTagName("div")[0];//get reference to the <div> containing the icon image
                    divElem.className = "rfeFileExtension " + dataItem.Extension.replace(".", "");//add the correct class names based on the dataItem extension

    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Joel Kraft
    Joel Kraft avatar
    92 posts
    Member since:
    Jan 2004

    Posted 13 Dec 2010 Link to this post

    That's an okay workaround, but I'm going to submit this as a suggestion.

    If someone can write a custom provider, then its not okay to assume that typical file name extension semantics would apply, especially if that provider is given an explicit mechanism to override that behavior.
Back to Top