I've been searching and and I cannot find a thread or answer for what I'm doing specifically. I have a site where a user will be creating a record called 'ManualProcess'. In the pop-up they will enter general information about the record and then with the Upload() select files to be uploaded and associated to this main record. The files will be stored in a separate table name 'ManualPrcoessDeocuments' with a FK relationship back to the 'ManualProcess' record.
What I'm trying to do is have the HttpPostedFileBase[] object be passed back to the controller along with the 'ManualProcess' record. I have been able to get it to call and pass a value using the async option but that occurs before they have sent the main record data. So ido not have the main record id to associate the documents with.
Below is the grid code.
@(Html.Kendo().Grid(Model).Name("ManualWorkflowProcess").Columns(c =>
{
c.Bound(e => e.Name);
c.Bound(e => e.Description);
c.Bound(e => e.ApprovalProcessName);
c.Bound(e => e.Active).ClientTemplate("<
input
type
=
'checkbox'
disabled
=
'disabled'
value
=
'#= Active #'
" + "# if (Active) { #" + "
checked
=
'Active'
" + "# } #" + "/>").Width(100);
c.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(200);
})
.ToolBar(toolbar => toolbar.Create().Text("Create New Process"))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ManualProcessPopUp").Window(w => w.Width(700)))
.Pageable(pager => pager.AlwaysVisible(false).PageSizes(new List<
object
> { 5, 10, 20, 100 }))
.Sortable()
.Filterable()
.Groupable()
.Events(events => events.Edit("Edit"))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(p => p.Id))
.Create(update => update.Action("EditingPopup_Create", "ManualApprovalProcesses"))
.Read(read => read.Action("EditingPopup_Read", "ManualApprovalProcesses"))
.Update(update => update.Action("EditingPopup_Update", "ManualApprovalProcesses"))
.Destroy(update => update.Action("EditingPopup_Destroy", "ManualApprovalProcesses"))
))
Below is the Upload() code in the pop-up template
<
div
class
=
"editor-label"
>
@Html.Label("Files", htmlAttributes: new { @class = "control-label col-md-10" })
</
div
>
<
div
class
=
"editor-field"
>
@(Html.Kendo().Upload().Name("FileUploads").HtmlAttributes(new { aria_label = "files" })))
</
div
>
Below is my controller code.
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ManualApprovalProcess manualProcess, HttpPostedFileBase[] fileUploads)
{
if
(manualProcess !=
null
&& ModelState.IsValid)
{
this
.Update(manualProcess);
}
return
Json(
new
[] { manualProcess }.ToDataSourceResult(request, ModelState));
}
So I want to have the file data passed back to the controller so I can create the main record and then use that id and loop over the documents and use that new id when creating the document records.
If this possible the way I'm trying to achieve this? I can;t do the async call because I will be missing come data that I need to properly upload and create the document records as well as upload them to the correct location in Azure.