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

Cannot read property 'code' of undefined (Object reference not set to an instance of an object from response)

Hi!

I'm implementing the FileManager but it's not working, it's throwing this error when loads: "Cannot read property 'code' of undefined"



The status is OK from the FileOperations:



This is the response:

"{\"cwd\":null,\"files\":null,\"error\":{\"code\":\"417\",\"message\":\"Object reference not set to an instance of an object.\",\"fileExists\":null},\"details\":null}"

Any idea what is wrong?

Thanks, regards!


Attachment: ControllerAndView_e9beddef.zip

8 Replies

AB Ashokkumar Balasubramanian Syncfusion Team October 9, 2019 09:42 AM UTC

Hi Daniel Colunga, 
 
Good day to you.  
  
We have checked your reported query that Cannot read property 'code' of undefined error in all possible cases, the issue occurs only whenever the root path doesn’t contain any files or folders. We are suspect the same case also happened at your end. For your reference we have prepared and attached a video to exhibit the request sending to the server side.  
  
  
Also, we have prepared a file manager sample in ASP.NET MVC. Refer the sample link below.  
  
   
Can you please check with attached video and sample? If the issue persist, can you please share the below requested additional details will be more helpful to identify your reported issue at earlier.   
 
            a. Video for issue reproducing.  
b. Code snippet for file manager operations in controller side.  
c. Issue reproducing sample (if possible).  
  
Regards,  
Ashokkumar B. 



DA Daniel October 9, 2019 07:29 PM UTC

Hi! Apparenly the version 17.1.41 of the "ej2.min.js" has something wrong because I used the last version of the ej2 and now it's working.

Regards!


DA Daniel October 9, 2019 07:49 PM UTC

One question, is it possible to create dinamically the paths? 

I want a single folder for each record (based on ID). For example, i'm sending the ID 1 to the index view, and I'm checking if in the root file exists that folder named "1", if not... create it, and set the root as de default + "/1".

Thanks, regards!


AB Ashokkumar Balasubramanian Syncfusion Team October 10, 2019 12:02 PM UTC

Hi Daniel Colunga,  
 
Most Welcome. 
 
We have checked another reported query that how to dynamically update the path of file manager component. Using Path API property, you can dynamically change the path of the file manager component. 
 
For your requirement, we have prepared a sample. In that sample, we can get the folder name from the textbox component during button click. After that, check the folder name is exist in the root folder, if doesn’t exist then create a folder in root path by using createFolder() method in file manager component. 
 
Refer the below code snippet for create a folder and navigate to new folder path. 
 
  onSubmit() {       
        var value = this.textbox.value; 
        var treedata = this.filemangerInstance.navigationpaneModule.treeObj.treeData 
        for (var i = 0; i < treedata.length; i++) { 
            // Checking the folder already exist or not. 
            if (treedata[i].name == value) { 
                this.count++ 
            } 
        } 
        if (this.count == 0) { 
            // Replace the path to the root path 
            this.filemangerInstance.path = "/"; 
            this.filemangerInstance.dataBind(); 
            // Create a new folder if folder doesn't exist 
            this.filemangerInstance.createFolder(value); 
            setTimeout(() => { 
                // Navigate the path to the newly created folder 
                this.filemangerInstance.path = "/" + value; 
                this.filemangerInstance.dataBind(); 
            }, 500) 
        } 
        this.count = 0; 
    } 
 
 
 
Please let us know, if you have any concerns. 
 
Regards, 
Ashokkumar B. 



DA Daniel October 10, 2019 02:49 PM UTC

Thanks, with your example I got an idea and it works. First, in the ActionResult Index, I created the new folder based on the passed ID:


Then, I pass to the view that ID and set it to the path:

And that's it. The only thing pending is that I want to hide the entire row where Breadcrum and search is... but I don't see any FileManager method to do this. Can you help me with this?



Thnaks, regards!


AB Ashokkumar Balasubramanian Syncfusion Team October 11, 2019 09:02 AM UTC

Hi Daniel Colunga,  
 
We are glad to hear that the provided solution worked for you. 
 
For hide the BreadCrumb and Search Box in File Manager component, you can use cssClass property to add the custom class for File Manager and use that class to hide. Please refer the below code block. 
 
<ejs-filemanager id='overview' #filemanager [ajaxSettings]='ajaxSettings' [view]='view' cssClass="myfilemanger"> 
</ejs-filemanager> 
 
.e-filemanager.myfilemanger .e-address { 
    display: none; 
} 
 
 
Could you please check the sample and get back to us, if you require any further assistance on this? 
 
Regards, 
Ashokkumar B. 



DA Daniel October 14, 2019 09:03 PM UTC

Yes, it's working.

Thanks for your help, regards!


KR Keerthana Rajendran Syncfusion Team October 15, 2019 06:17 AM UTC

Hi Daniel,  
 
Most welcome. We are glad that the issue has been resolved in your end. Please get back to us if you need further assistance on this.  
 
Regards, 
Keerthana.  


Loader.
Live Chat Icon For mobile
Up arrow icon