how to load a combo into a window?

1 Answer 130 Views
Window
Israel
Top achievements
Rank 1
Israel asked on 04 Nov 2021, 03:28 PM

I am trying to load a combobox inside a kendo window, but it does not load me. the code I have is the following:

@{Html.Kendo().Window()
.Name("winAplicar")
.Title(Resource.TituloAsignar)
.Draggable(false)
.Scrollable(false)
.Modal(true)
.Width(950)
.Height(200)
.Visible(false)
.Render();
}

the following function takes care of obtaining the model that will contain the window

function abrirVentana() {
            var win = $("#winAplicar").data("kendoWindow");
            var url = '@Url.Action("_CambiarEstatus", "AsignaPoliticaPago", new { area = "Nomina" })';

            win.refresh({
                url: url
            });
            setTimeout(function () {
                win.center().open();
            }, 200)
        }

                            

public ActionResult _CambiarEstatus(SecurityContext securityContext)
        {

                return View(new AsignaPoliticaPagoViewModel() { CLA_POLITICA_PAGO2 = 2 });

        }

but it only shows it in blank

 

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 09 Nov 2021, 11:39 AM

Hello Israel,

You could display a ComboBox inside the Window as per the example below:

  • Define the Window and call the refresh() method when a specified button is clicked:

 

<button id="openWindow" class="k-button">Open</button>

@{Html.Kendo().Window()
  .Name("winAplicar")
  .Title("Test")
  .Draggable(false)
  .Scrollable(false)
  .Modal(true)
  .Width(950)
  .Height(200)
  .Visible(false)
  .Render();
}

<script>
    $("#openWindow").on("click", function () {
        var wnd = $("#winAplicar").data("kendoWindow"); //get an instance of the Window
        win.refresh({
            url: '@Url.Action("GetWindowContent", "ControllerName")'
        });
        wnd.center().open(); //open it
    });
</script>

 

  • Return the View with the ComboBox:

 

//Controller
public ActionResult GetWindowContent()
{
            ViewData["categories"] = GetCategories();
            return PartialView("_WindowContentView", new CategoryViewModel() { CategoryID = 5, CategoryName = "Category 5" });
}

//View (_WindowContentView.cshtml)
@model ProjectName.Models.CategoryViewModel

@(Html.Kendo().ComboBoxFor(m => m.CategoryID)
          .Filter(FilterType.Contains)
          .DataTextField("CategoryName")
          .DataValueField("CategoryID")
          .BindTo((System.Collections.IEnumerable)ViewData["categories"])
          .Suggest(true)
    )

Hopefully, this example will be helpful to your case.

Regards, Mihaela Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Window
Asked by
Israel
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or