3

I have a Kendo grid:

@(Html.Kendo().Grid<Grid>().Name("Grid")
      .DataSource(ds => ds
          .Ajax()
          .Model(model => model.Id(m => m.ID))
          .Read(read => read.Action("Grid_Read", "Sessions", new {sessionId = ViewBag.SessionID}))
              .Update(update => 
update.Action("Grid_Update", "Sessions", new { 
sessionId = ViewBag.SessionID, qcStateId = '????'}))
              .PageSize(10)
              .Batch(true)
          )
          .ToolBar(toolbar => 
          {
              toolbar.Template(
                    "| Set selected to: " + @Html.Partial("EditorTemplates/QCStatusHeader"));
          }
          )

QCStatusHeader:

@(Html.Kendo().DropDownList()
    .Name("QCStatusHeader")
    .DataValueField("Id")
    .DataTextField("Name")
    .BindTo((List<NomadBase.Web.ViewModels.Shared.QCStateViewModel>)ViewBag.PossibleQCStatesHeader)

)

How do I get the selected value from the QCStatusHeader dropdownlist into my update call to the controller?

Shawn
  • 2,356
  • 6
  • 48
  • 82

1 Answers1

4

Pretty simple solution, add the .Data option with a javascript method to return the currently selected value of the ddl.

.Update(update => update.Action("Grid_Update", "Sessions", new {sessionId = ViewBag.SessionID})
    .Data("QCStatusHeaderValue"))

function QCStatusHeaderValue() {
        var value = $('#QCStatusHeader').data("kendoDropDownList").value();
        return { qcStateId: value };
    }
Shawn
  • 2,356
  • 6
  • 48
  • 82