Placing other Kendo widgets inside Content of Window for ASP.NET MVC

948 views Asked by At

Is it possible to use razor syntax to add kendo widgets inside of the Content of a Kendo Window?

Here is an example of what I am trying to do but the kendo widgets aren't loading properly:

    <div id="window1"></div>

    @(Html.Kendo().Window()
          .Name("productWindow")
          .Title("Additional Settings")
          .Width(400)
          .Modal(true)
          .AppendTo("#window1")
          .Visible(false)
          .Actions(actions => actions.Minimize().Maximize().Close())
.Content(@<text>
    <label asp-for="ProductId"></label>
    @(Html.Kendo().DropDownList()
                      .Name("ProductId")
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .BindTo(new List<SelectListItem>() {
                          new SelectListItem() {
                              Text = "Prod 1",
                              Value = "1"
                          },
                          new SelectListItem() {
                              Text = "Prod 2",
                              Value = "2"
                          },
                          new SelectListItem() {
                              Text = "Prod 3",
                              Value = "3"
                          },
                          new SelectListItem() {
                              Text = "Prod 4",
                              Value = "4"
                          }
                      })
                      .Value("2")
                      .HtmlAttributes(new { style = "width: 100%" })
                      .Deferred()
    )
    <span asp-validation-for="ProductId" class="text-danger"></span>
        </text>)
          .Deferred()
    )
1

There are 1 answers

3
Ross Bush On

You can have the window make another call to ask for it's content. That call will return the partial with the view for the window.

In Parent View

@model ProductFormViewModel 

@(Html.Kendo().Window().LoadContentFrom("Action", "Controller",new object{"detailID",model.DetailID);

Controller

public ActionResult Action(int detailID)
{
    var detailModel=LoadDetail(DetailID);
    return PartialView("MyWindowPartual",detailModel);
}

Window Detail PartialView

@model AdvancedProductSettingsViewModel

@(Html.Kendo().DropDownList()...

And have the controller return a View() or PartialView().