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. Image for the cookie policy date
close icon

How can i post with my parameter when i click the left Directory

I user the ejFileExplorer with Asp.net Mvc , the directory and file data source from Sql Server., and my "ajaxAction" returned json contains id.How can i set the file's id or directory's id by js. and how can i post the id when i click the directory or file.
Thanks~


5 Replies

XY xycool August 4, 2016 04:52 AM UTC

I already known how to set the id to the files,but why i can't set the id to the directory.I find the directory's id same as the name.How can i change the directory id.

one more question。
 $("#fileExplorer").ejFileExplorer({
                isResponsive: true,
                width: "100%",
                fileTypes: "*.png,*.gif,*.jpg,*.jpeg,*.docx",
                toolsList: toolsList,
                layout: "tile",
                //tools: tools,
                path: "公共文件",
                ajaxAction: localServ,
                ajaxDataType: ajaxDataType,
                ajaxSettings: {
                    read: {
                        url: localServ,
                        dataType: "json",
                        data: { FileID: "" },
                        success: function (rsp) {
                            console.log(rsp);
                        }
                    },
                    rename: {
                        url: localServ,
                        dataType: "json",
                        data: { Type: "", FileID: "" }
                    },
                    upload: {
                        url: "@ViewBag.FileUploadURL",
                        success: function (rsp) {
                            console.log(rsp);
                        }
                    }
                },
                uploadSettings: { allowMultipleFile: false }
                
            });
 Q:after the ejFileExplorer read data,the chrome can console.log(rsp),but after i uploaded the file,it's can't perform the console.and the my webapi return success.


XY xycool August 4, 2016 09:07 AM UTC

Oh,I have known to set the callback func about upload success.Now I need help about tow question.

Q1: How can i set the directory id,beacuse the webApi has returned id,but when i selected the directory,i finded the directory'id same as the name.the file id is normal.

Q2:How can i change the "src" for the files .  All of my files throw 404 error.like <img>..

Looking forward to reply,Thank you!


BP Balamurugan P Syncfusion Team August 4, 2016 10:11 AM UTC

Dear customer,   
  
Thanks for using Syncfusion products.   
 
We have analyzed your query “How can I set the file's id or directory's id by JS in order to manage the files in SQL Database”. By default, we have stored and processed the returned JSON data internally and also these details will be posted automatically, while performing file related operations (like read, rename, upload, download, delete, etc.) in FileExplorer. So no needed to process these “id” details externally.    
 
For your convenience, we have provided a custom sample (FileExplorer with SQL database). Here you can use this custom “SQLFileExplorerOperations" class for handling file management related operations using SQL database. This class is used to simplify the process on server side. It contains some built-in methods that are used to handle file operations (like read, copy, move, delete, etc.) using SQL database. This class is created by inheriting the abstract classBasicFileOperations”. If it’s necessary, you can override the methods in “SQLFileExplorerOperations” class.   
   
·         To make connection with SQL database (FileManager.mdf) services, please specify connection string in "Web.config" file as specified in the following code example.    
<add name="FileExplorerConnection" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\FileManager.mdf;Integrated Security=True;Trusted_Connection=true" />   
    
·         In controller part, you need to create an object of "SQLFileExplorerOperations" class as shown in the following code example.   
//Here "FileExplorerConnection" is a connection string name, which is defined in Web.config file.    
//"Product" is a table name, which is defined in SQL database   
SQLFileExplorerOperations sqlobj = newSQLFileExplorerOperations("FileExplorerConnection""Product");   
  
   
After creating the object for “SQLFileExplorerOperations” class in controller part, Manually call the corresponding built-in file operation handling methods available in “SQLFileExplorerOperations” class based on the file operation type.   
 
We have prepared the following sample based on this, FileExplorer sample  
 
Please let us know whether the provided sample is helpful in achieving your requirement or not. If you have any other requirement, please get back with the details, we will happy to assist you.   


  
Regards,   
Balamurugan P   



XY xycool August 5, 2016 02:35 AM UTC

Thank you for you answer.
It's my controller return json when the ejFileExplorer read,you can see these folders have id.


But when i click the directory ,i watch the "args.data.SelectedItems",the id same as name,so i can't load file by this id.so i can't understand about this.

and one more question. How can i change the "src" for the files .the default scr from ejFileExplorer paht. so  all of my files throw 404 error.like <img>..

Looking forward to reply,Thank you!


BP Balamurugan P Syncfusion Team August 5, 2016 11:16 AM UTC

Dear customer, 
 
Q1: How can I set the directory id, because the webApi has returned id, but when I selected the directory, I found the directory id same as the name of the file id is normal. 
 
In your returning JSON, please use some other nameitemId instead of using the name “id”, since it conflicts with the “id” of html elements, which is available in the FileExplorer control. So refer following image, that will helps you to solve this problem. 

 
 
    public class SQLFileExplorerDirectoryContent 
    { 
        public int itemId { get; set; } 
        public string dateModified { get; set; } 
        public bool hasChild { get; set; } 
        public bool isFile { get; set; } 
        public string name { get; set; } 
        public object size { get; set; } 
        public string type { get; set; } 
        public int parentID { get; set; } 
        public string filterPath { get; set; } 
    } 
 
Now “SelectedItems” hold the selected SQL record id in “itemID” parameter. 
 
 
Q2: How can I change the "src" for the files .  All of my files throw 404 error like <img>.. 
 
Please refer following code block to customize the source path of image files as per your requirement. Here {0} parameter replaces with internal data. 

    $("#fileExplorer").ejFileExplorer({ 
        path: "????", 
        ajaxAction: localServ, 
        ajaxDataType: ajaxDataType, 
        ajaxSettings: { 
            getImage: { 
                //change the "src" for the files. which throw 404 error.like <img>.. 
                url: "GetImage{0}" 
            } 
        } 
    }); 

Refernce format for requesting image file 
 

Please let us know if you require any further assistance. 

Regards, 
Balamurugan P 


Loader.
Live Chat Icon For mobile
Up arrow icon