Hi,
I'm using a Grid popup editing with custom editor I'd like to use upload control with initially files loaded from a path that depends by the Id field (taskID) of the ViewModel (TaskViewModel).
Here it is the code I'm using:
@(Html.Kendo().Grid<Telerik_Tecnim.Models.TaskViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.taskID);
columns.Bound(o => o.Cont);
....
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Model(model =>
{
model.Id(o => o.taskID);
model.Field(o => o.taskID).Editable(false);
....
})
.Create(update => update.Action("Task_Create", "Task", new { id = "#=ticketID#" }))
.Read(read => read.Action("Task_Read", "Task", new { ticketID = "#=ticketID#" }))
.Update(update => update.Action("Task_Update", "Task"))
.Destroy(update => update.Action("Task_Destroy", "Task"))
)
.Pageable()
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Task")))
.Sortable()
.ToClientTemplate()The editor template, task.cshtml, is:@model Telerik_Tecnim.Models.TaskViewModel
...
<div>
@(Html.Kendo().Upload()
.Name("files")
.Async(a => a
.Save("SaveAndPersist", "Upload", new { id = "#=taskID#" })
.Remove("RemoveAndPersist", "Upload", new { id = "#=taskID#" })
.AutoUpload(true)
)
.Files(files =>
{
foreach (var f in Model.UploadFiles)
{
files.Add().Name(f.Name).Extension(f.Extension).Size(f.Size);
}
})
)
</div>
TaskViewModel is:
...
namespace Telerik_Tecnim.Models
{
public int taskID { get; set; }
....
public class TaskViewModel
{
.....
public IList<Telerik_Tecnim.Models.UploadFileViewModel> UploadFiles
{ get
{ return SessionUploadInitialFilesRepository.GetAllInitialFiles(this.taskID);
} set
{ } }
}
}
Unfortunately Model.UploadFiles in editor template seems to be empty (any file is show in uplaod control) but if I check the data with Fiddler UploadFiles is not empty!
How to use upload with initially files in editor template from a variable path depended by a field of the model?
Thanks in advance
I'm using a Grid popup editing with custom editor I'd like to use upload control with initially files loaded from a path that depends by the Id field (taskID) of the ViewModel (TaskViewModel).
Here it is the code I'm using:
@(Html.Kendo().Grid<Telerik_Tecnim.Models.TaskViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.taskID);
columns.Bound(o => o.Cont);
....
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Model(model =>
{
model.Id(o => o.taskID);
model.Field(o => o.taskID).Editable(false);
....
})
.Create(update => update.Action("Task_Create", "Task", new { id = "#=ticketID#" }))
.Read(read => read.Action("Task_Read", "Task", new { ticketID = "#=ticketID#" }))
.Update(update => update.Action("Task_Update", "Task"))
.Destroy(update => update.Action("Task_Destroy", "Task"))
)
.Pageable()
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Task")))
.Sortable()
.ToClientTemplate()The editor template, task.cshtml, is:@model Telerik_Tecnim.Models.TaskViewModel
...
<div>
@(Html.Kendo().Upload()
.Name("files")
.Async(a => a
.Save("SaveAndPersist", "Upload", new { id = "#=taskID#" })
.Remove("RemoveAndPersist", "Upload", new { id = "#=taskID#" })
.AutoUpload(true)
)
.Files(files =>
{
foreach (var f in Model.UploadFiles)
{
files.Add().Name(f.Name).Extension(f.Extension).Size(f.Size);
}
})
)
</div>
TaskViewModel is:
...
namespace Telerik_Tecnim.Models
{
public int taskID { get; set; }
....
public class TaskViewModel
{
.....
public IList<Telerik_Tecnim.Models.UploadFileViewModel> UploadFiles
{ get
{ return SessionUploadInitialFilesRepository.GetAllInitialFiles(this.taskID);
} set
{ } }
}
}
Unfortunately Model.UploadFiles in editor template seems to be empty (any file is show in uplaod control) but if I check the data with Fiddler UploadFiles is not empty!
How to use upload with initially files in editor template from a variable path depended by a field of the model?
Thanks in advance