Is it possible to add the size unit like Mb or Kb to file explorer

2 posts, 0 answers
  1. koteswararao
    koteswararao avatar
    39 posts
    Member since:
    Aug 2010

    Posted 29 Oct 2012 Link to this post

    hi expert,
    i am working with telerik file explorer form last 2 weeks can you please suggest the way / possibility
    1 ) to show the size uint like (kb ,mb ) beside the the size number in the second pane
    2) when we upload the file ,in the upload window when we click on add button we get unlimited select (browse) s
    is there any way to restrict to some n number of selects
    let me know the possibility for those if possible please suggest me how can we show the unit metric along with file

    i hope you understand my issue .

    Thanks & Regards,
    m.koteswara Rao.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Oct 2012 Link to this post

    Hi,

    1) Try the following code snippet to add file size unit in the RadFileExplorer.

    ASPX:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="OnClientFolderLoaded" OnClientFolderLoaded="OnClientFolderLoaded"  >
        <Configuration ViewPaths="~/" UploadPaths="~/" DeletePaths="~/" />
    </telerik:RadFileExplorer>

    JS:
    <script type="text/javascript">
        function OnClientFolderLoaded(sender, args) {
            var radExplorer = $find('<%= RadFileExplorer1.ClientID %>');
            var getGrid = radExplorer.get_grid();
            var table = getGrid.get_masterTableView();
            var rows = table.get_dataItems();
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                var sizeInBytes = row.get_cell("Size").innerHTML;
                var inegerValue = -1;
                try {
                    inegerValue = parseInt(sizeInBytes);
                }
                catch (err) {
                    inegerValue = -1;
                }
                if (inegerValue > 0) {
                    var textInKB = Math.round(inegerValue / 1024);
                    if (textInKB < 1) {
                        textInKB = 1;
                    }
                    textInKB = textInKB + " KB";
                    row.get_cell("Size").innerHTML = textInKB;
                }
            }
        }
    </script>

    2) You can set the MaxFileInputsCount of the Upload to limit the number of uploaded files.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadFileExplorer1.Upload.MaxFileInputsCount = 3;
    }

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top