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

How to access values outside of grid during grid update

1 Answer 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 16 Feb 2016, 08:48 PM

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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 18 Feb 2016, 01:18 PM
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
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or