Kendo UI Grid displayed in a Kendo Window as a modal dialog posts back to a new blank page

2.3k Views Asked by At

I am using a Kendo UI Grid inside a Kendo UI Window in my ASP.NET MVC 4 application. The window that the grid is displayed in is modal.

Here's the definition of the Kendo UI Window.

@(Html.Kendo().Window()
    .Name("BackupSearchResultsPopupWindow")
    .Draggable()
    .Actions(actions => actions.Close())
    .AutoFocus(true)
    .Modal(true)
    .Events(events => { events.Close("OnBackupSearchResultsPopupWindowClose"); })
    .Width(600)
    .Height(400)
    .Title("Requestors matching your search query")
    .Visible(false)

When I display this window, it displays fine and the grid inside it has data, but when I try to sort the grid by any of its columns by clicking on the column header, the grid posts back to its controller action rightly but the modal window is gone and so is the page behind the modal window and the browser is refreshed to a new page that is to have the grid results.

Also, the grid results do not display.

Here is the code inside the razor view that has the window.

@(Html.Kendo().Grid<Backup>()
.Name("MatchingBackupsGrid")
.Columns(col =>
    {
        col.Bound(backup => backup.BackupUId).Title("UID");
        col.Bound(backup => backup.BackupFirstName).Title("First Name");
        col.Bound(backup => backup.BackupLastName).Title("Last Name");
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Selectable(sel =>
    {
        sel.Mode(GridSelectionMode.Single);
        sel.Type(GridSelectionType.Row);
    })
    .DataSource(dataSource => dataSource            
         .Server()
         .Read(read => read.Action("SearchForBackup", "Arr", 
                            new { lastName = ViewBag.SearchTerm }))
         .Model(model => model.Id(b => b.BackupUId)))

         .BindTo(Model)
    )
1

There are 1 best solutions below

0
On

Ensure there are no Javascript errors using browser developer tools. I have also faced the same problem once the javascript errors are corrected it is working fine.

If Kendo encounters any javascript error it uses server posting rather than Ajax posting