1
votes

Hi can we 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 db based on button click.

Can someone tell me how to achieve this? Is there any example available?

Thanks

1
Put the Grid in the pop up like you would put anything else in there.CSharper
Hi thanks for the reply. Yes I'm placing grid but I want to call the databind method based on button. i.e I've 3 buttons and I want to load the same popup window. And here I want to change the datasource based on each button. Ex. If I click on button1 I want to call different datasource ("/Employees/1", "/Employees/2", "Employees/3"). Same for other two.jestges
Check out my edit, if you have to then set up multiple window.Refresh methods and call the correct one using an IF statementCSharper

1 Answers

2
votes

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"  />&nbsp;
        <input type="submit" id="btnSave" name="command" value="Save" />&nbsp;
        <input type="submit" id="btnApply" name="command" value="Apply" />&nbsp;

    [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