How to access values outside of grid during grid update

2 posts, 1 answers
  1. Jason
    Jason avatar
    2 posts
    Member since:
    Dec 2015

    Posted 16 Feb Link to this post

    I am at a disadvantage because not only am I new to Kendo UI, but I am new to MVC as well.

    Using the Save method inside Kendo UI Grid, I ALSO need to access a selected value from a Kendo Drop Down List.

    For the life of me, I cannot figure out how to access the value.

    Can someone assist? 

    Here is some code:

    Drop Down List:

    @(Html.Kendo().DropDownListFor(m => m.SelectedPrinter)
    .Name("Printers")
    .HtmlAttributes(new { style = "width:100%" })
    .OptionLabel("Select printer...")
    .DataTextField("Name")
    .DataValueField("ID")
    .DataSource(source =>
    {
    source.Read(read =>
    {
    read.Action("GetCascadePrinters", "Home")
    .Data("filterProducts");
    })
    .ServerFiltering(true);
    })
    .Enable(false)
    .AutoBind(false)
    .CascadeFrom("Locations")
    )

    Grid:

    .DataSource(dataSource => dataSource.Ajax()
    .Model(
    model =>
    {
    model.Field(f => f.UserName).Editable(false);
    model.Field(f => f.FirstName).Editable(false);
    model.Field(f => f.LastName).Editable(false);
    model.Field(f => f.PrincipalCreationDate).Editable(false);
    model.Id(p => p.UserName);
    }
    )
    .Read("Editing_Read", "Home")
    .Update("Editing_Update", "Home")
    .ServerOperation(false)
    .Batch(true)

    Controller:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Editing_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<User> usr, UsersViewModel uvm, string SelectedPrinter)
    {

    // Check if model is valid
    // Get User from UserID
    // Build Trigger File
    // Send to Bartender Trigger Directory
    if (usr != null && ModelState.IsValid)
    {
    foreach (var product in usr)
    {
    // productService.Update(product);
    }
    }
    return Json(usr.ToDataSourceResult(request, ModelState));
    }

    Any Help is appreciated.

  2. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 18 Feb Link to this post

    Hi Jason,

    Thank you for contacting us.

    You can use a particular event (e.g., saveChanged, edit), where you can get the selected item of the dropdownlist:
    alert($("#dropdownlist").data("kendoDropDownList").select());

    I can also suggest that you examine the getting started resources of Kendo UI controls the corresponding MVC wrappers:
        - http://docs.telerik.com/kendo-ui/introduction
        - http://docs.telerik.com/kendo-ui/aspnet-mvc/introduction

    Let me know if I can assist you further with our products.

    Regards,
    Danail Vasilev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top