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

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

1 Answer 174 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
koteswararao
Top achievements
Rank 1
koteswararao asked on 29 Oct 2012, 07:29 AM
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.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Oct 2012, 09:12 AM
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.
Tags
FileExplorer
Asked by
koteswararao
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or