FileManager Create DataSource call not sending necessary data to server

0 Answers 26 Views
FileManager
Cary
Top achievements
Rank 1
Cary asked on 13 Aug 2021, 05:24 PM

I am using Telerik UI for ASP.NET MVC R2 2021 SP1 (2021.2.616)  in VB.net, Visual Studio 2019

I have added a FileManager to an MVC view following the code in the Basic Usage demo (https://demos.telerik.com/aspnet-mvc/filemanager) and everything is working correctly, except when I try to implement the code for the New Folder button (Which fires the Create command on the DataSource).


@Html.Kendo().FileManager().Name(Model.ControllerName & "_FileManager").DataSource(Sub(ds)
	ds.Read(Sub(r)
		r.Type(HttpVerbs.Post).Action("Read", Model.ControllerName)
	End Sub)
	ds.Create(Sub(c)
		c.Type(HttpVerbs.Post).Action("Create", Model.ControllerName)
	End Sub)
	ds.Update(Sub(u)
		u.Type(HttpVerbs.Post).Action("Update", Model.ControllerName)
	End Sub)
End Sub).Upload(Sub(u)
	u.Validation(Sub(v)
		v.AllowedExtensions(Model.AllowedFileExtensions)
	End Sub)
End Sub).UploadUrl("Upload", Model.ControllerName).Toolbar(Sub(t)
		t.Items(Sub(i)
		i.Add("createFolder")
		i.Add("upload")
		i.Add("sortDirection")
		i.Add("sortField")
		i.Add("spacer")
		i.Add("search")
	End Sub)
End Sub).InitialView("grid").ContextMenu(Sub(c)   
	c.Items(Sub(i)
		i.Add("download").Command(Model.ControllerName & "DownloadCommand").Text("Download").SpriteCssClass("k-icon k-i-download")
	End Sub)
End Sub)


On the demo page, if you have the developer tab open to the Network, when clicking the New Folder button you can see the request that is sent to the url defined in the Create endpoint and it contains the target path as well as the data for a FileManagerEntry object for the New Folder in the Form Data:

When I click the button in my FileManager view I can see the Form Data only includes the target property but none of the others:

Here is the code for the Create function in my Controller (it's almost identical to the demo code):


        Public Function Create(ByVal target As String, ByVal entry As FileManagerEntry) As ActionResult
            Dim newEntry As FileManagerEntry

            If String.IsNullOrEmpty(entry.Path) Then
                newEntry = CreateNewFolder(target, entry)
            End If

            Return Json(VirtualizePath(newEntry))
        End Function

I have not been able to figure out why the FileManager in my view is not returning the same data to the controller that the demo one does.

Any help would be greatly appreciated.

Ivan Danchev
Telerik team
commented on 18 Aug 2021, 04:15 PM

Hello,

The posted FileManager configuration is correct, so the problem is elsewhere. Could you check your Read action response and verify it has the respective fields for the folders loaded initially, before attempting to add a new folder?

Here's how the response in our demo looks like:

[
   {
      "Name":"Documents",
      "Size":0,
      "Path":"Documents",
      "Extension":"",
      "IsDirectory":true,
      "HasDirectories":false,
      "Created":"\/Date(1629295202707)\/",
      "CreatedUtc":"\/Date(1629295202707)\/",
      "Modified":"\/Date(1629295202722)\/",
      "ModifiedUtc":"\/Date(1629295202722)\/"
   },
   {
      "Name":"Images",
      "Size":0,
      "Path":"Images",
      "Extension":"",
      "IsDirectory":true,
      "HasDirectories":false,
      "Created":"\/Date(1629295202738)\/",
      "CreatedUtc":"\/Date(1629295202738)\/",
      "Modified":"\/Date(1629295202832)\/",
      "ModifiedUtc":"\/Date(1629295202832)\/"
   }
]

Additionally, can you attach a sample project that demonstrates the problematic behavior?

 

No answers yet. Maybe you can help?

Tags
FileManager
Asked by
Cary
Top achievements
Rank 1
Share this question
or