Can I put a kendo grid in a kendo popup window? I'm trying to open a popup window on button click and show data from my database based on button click.
How can I achieve this? Is there any example available?
Set up your Window Popup
@(Html.Kendo().Window()
.Name("searchWindow")
.Title("Manage Filters")
.Draggable(true)
.Resizable()
.Scrollable(false)
.Width(780)
.Height(500)
.Visible(false)
.Iframe(true)
.Modal(true)
.Events(m=>m.Close("CloseRefresh"))
)
Launch it on a Click event
$("#btnManageFilters").click(function () {
var window = $("#searchWindow").data("kendoWindow");
window.refresh({
url: "/Order/ListSavedSearches"
});
window.title("Manage Filters");
window.center();
window.open();
});
Define your Grid in a Partial View and return it
public ActionResult ListSavedSearches()
{
OrderGridViewModel ogvm = new OrderGridViewModel();
ogvm = //populate;
return PartialView("_OrderSearchParameters", ogvm);
}
Edit:
If your posting a Form and it has multiple buttons you need to set them up with the same name
and take that value as an argument in your Controller.
<input type="submit" id="btnNew" name="command" value="New" />
<input type="submit" id="btnSave" name="command" value="Save" />
<input type="submit" id="btnApply" name="command" value="Apply" />
[HttpPost]
public ActionResult SaveParameters(ViewModel model, string command)
string command
will have the value
of whatever what was clicked. So if clicked btnSave, then
command will equal "Save" run a switch statement based on the command passed in.
If your buttons don't post to a form then get the value using JQuery, this.val()
should work inside the buttons click event. And pass it through the Query string inside window.refresh({})
method mentioned above