We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

is there any API to display number of items in a folder next to folder name in Navigation pane?

Thread ID:

Created:

Updated:

Platform:

Replies:

150927 Jan 24,2020 11:55 AM UTC Feb 3,2020 04:18 AM UTC ASP.NET MVC - EJ 2 3
loading
Tags: FileManager
Unknown
Asked On January 24, 2020 11:55 AM UTC

We want to display number of items/files/folders in a folder next to it's name in navigation pane. is there any API to acheive this? 

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On January 30, 2020 11:55 AM UTC

Hi Mahesh, 
 
Greetings from Syncfusion support. 
 
We have checked your requirement to display the files/folders count in navigation pane of EJ2 File Manager. To achieve your requirement, you can pass the additional parameter (file count) from server side and process the variable in client side using fileLoad() event. 
 
Refer the below code snippet for server side (controller side). 

  public ActionResult FileOperations(FileManagerDirectoryContent args) 
        { 
            switch (args.Action) 
            { 
                case "read": 
                    return Json( JsonConvert.SerializeObject(this.getFiles(args), new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } })); 
            } 
            return null; 
        } 
public FileResponse getFiles(FileManagerDirectoryContent args) 
        { 
            FileResponse readResponse = new FileResponse(); 
            try 
            { 
                var value = operation.GetFiles(args.Path, args.ShowHiddenItems); 
                DirectoryContent cwd = new DirectoryContent(); 
                readResponse.CWD = JsonConvert.DeserializeObject<DirectoryContent>(JsonConvert.SerializeObject(value.CWD)); 
                readResponse.CWD.FolderCount = Directory.GetDirectories(this.basepath).Length.ToString(); 
                readResponse.CWD.FileCount = Directory.GetFiles(this.basepath).Length.ToString(); 
                readResponse.CWD.File_Folder = (Int32.Parse(readResponse.CWD.FolderCount) + Int32.Parse(readResponse.CWD.FileCount)).ToString(); 
                readResponse.Files = JsonConvert.DeserializeObject<IEnumerable<DirectoryContent>>(JsonConvert.SerializeObject(value.Files)); 
                foreach (DirectoryContent file in readResponse.Files) 
                { 
                    //Get the count of Folder 
                    file.FolderCount = !file.IsFile ? Directory.GetDirectories(this.basepath + file.FilterPath + file.Name).Length.ToString(): "0"; 
                    // Get the count of File 
                    file.FileCount = !file.IsFile ? Directory.GetFiles(this.basepath + file.FilterPath + file.Name).Length.ToString(): "0"; 
                    // Get the file and folder count added 
                    file.File_Folder = !file.IsFile ? (Int32.Parse(file.FolderCount) + Int32.Parse(file.FileCount)).ToString(): "0"; 
                } 
                readResponse.Details = value.Details; 
                readResponse.Error = value.Error; 
                return readResponse; 
            } 
            catch 
            { 
                ErrorDetails er = new ErrorDetails(); 
                return readResponse; 
            } 
        } 

Refer the client-side code. 
 
                  function fileLoad(args) { 
        if (args.module == "NavigationPane") { 
            // Display both the file and folder count 
            //var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.file_Folder + ")"; 
            // Display the Files Count only 
            var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.fileCount + ")"; 
            // Display the Folder Count Only. 
            //var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.folderCount + ")"; 
            args.element.querySelector(".e-list-text").innerText = element; 
        } 
    } 

For your reference, we have prepared a sample. In that sample, we have displayed a fileCount/folderCount. Refer the sample link below. 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 


Unknown
Replied On January 31, 2020 01:24 PM UTC

Thank you

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On February 3, 2020 04:18 AM UTC

Hi Mahesh, 
  
Welcome. Please, get back to us if you need any other assistance. 
  
Regards, 
Shameer Ali Baig S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon