This is a migrated thread and some comments may be shown as answers.

Grid Editable window LoadContentFrom with rout value ?

0 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Khieu Kim Khun
Top achievements
Rank 1
Khieu Kim Khun asked on 21 Sep 2012, 09:16 AM
Hi,

I am a new programmer with Kendo UI on MVC, I have a question to ask supporter.
I am using Kendo Grid call popup window when I edit button click like code below :

@(Html.Kendo().Grid<tblAttachFile>()
    .Name("tblAttachFile")
    .BindTo(Model.tblAttachFiles)
    .Columns(col =>
    {
        col.Bound(p => p.Attach_File_Name).Title("File Name");
        col.Bound(p => p.Attach_File_Path).Title("File Path");
        col.Bound(p => p.Attach_File_Description).Title("File Description");
        col.Command(cmd => cmd.Edit());
    })
        //.ToolBar(toolbar => toolbar.Create())
    .Editable(ed => ed.Mode(GridEditMode.PopUp).Window(w => w.Name("winEdit").Title("My Test").Content("Loading").LoadContentFrom("Edit", "AttachFile", new { id = 1 })))
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(ds => ds
        .Server()
        .Model(m => m.Id(p => p.Attach_File_ID))
        .Update("Edit", "AttachFile")
        )
)

I want to get Attach_File_ID in to route value in this line 
.Editable(ed => ed.Mode(GridEditMode.PopUp).Window(w => w.Name("winEdit").Title("My Test").Content("Loading").LoadContentFrom("Edit", "AttachFile", new { id = Attach_File_ID })))
When I enter id number like (1, 2, 3) it is work correct.

How can I get dynamic ID in route value ?

This code below is my controller that I want to do :
// GET: /tblAttachFiles/Edit/5
[Authorize]
public ActionResult Edit(int id)
{           
    tblAttachFile tblattachfile = tblattachfileRepository.GetOne(id);
    ControllerHelper.filePath = tblattachfile.Attach_File_Path;
    return View(tblattachfile);
}
 
//
// POST: /tblAttachFiles/Edit/5
 
[AcceptVerbs(HttpVerbs.Post), Authorize]
public ActionResult Edit(int id, FormCollection collection)
{
    tblAttachFile tblattachfile = tblattachfileRepository.GetOne(id);
    try
    {
        tblattachfile.Attach_File_Path = ControllerHelper.filePath;
        ControllerHelper.filePath = "";
 
        tblattachfile.Updated_Date = DateTime.Now;
        tblattachfile.Updated_By = User.Identity.Name;
 
        UpdateModel(tblattachfile);
        tblattachfileRepository.Save();
        return RedirectToAction("Detail", new { id = tblattachfile.Attach_File_ID });
    }
    catch
    {
        ModelState.AddRuleViolations(tblattachfile.GetRuleViolations());
        return View(tblattachfile);
    }
}

Thank advanced,
Sorry For my bad English !
KHUN

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Khieu Kim Khun
Top achievements
Rank 1
Share this question
or