Telerik MVC grid problems
Ok, Telerik has some good visual appealing controls, but it damn hard to use and too diferent from html programming.
My problem: I had in my page a grid with ajax turned on. So sorting, paging.. are made with ajax calls to my controllers. In this page there is a link to open a window (telerik one..), this windows is opened with this javascript code:
$(".bs-icon").live("click", function () {
var windowElement = $.telerik.window.create({
Name: "myWindow",
title: "Pesquisa",
modal: true,
resizable: false,
draggable: true,
scrollable: false,
visible: false,
width: 500,
height: 400,
onClose: function () { }
});
var w = windowElement.data("tWindow");
w.ajaxRequest("Alerts/IndexLookup/");
w.center().open();
});
In this window there is another grid, but I can´t get the ajax to work with this second grid. Something is turned off and I don´t know what it is.
Thanks.
Changed the javascript to this:
$.get("/AlertaGeral/IndexLookup",
function (response) {
$("#form-temp").html(response);
});
return false;
to get off telerik windows. Same problem. The grid that comes from ajax request does not works properly. Maybe some setup is missing after including it in the page.
Here is AlertaGeralController:
public ActionResult IndexLookup(Consulta.FiltroPadrao filtro = null)
{
if (Session["token"] == null)
return RedirectToAction("Index", "Home");
if (filtro == null)
filtro = new Consulta.Filtro开发者_Go百科Padrao { Descricao = null };
ResultadoPadrao[] registros = consulta.Pesquisar(Session["token"].ToString(), "SamAlertageral", filtro);
Session["ultimoFiltro"] = filtro;
return PartialView("_GridPesquisaLookup", registros);
}
and the view _GridPesquisaLookup.cshtml:
@model Benner.Saude.Consulta.ResultadoPadrao[]
@(Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Handle))
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("AjaxPesquisarLookup", "AlertaGeral")
)
.HtmlAttributes(new { @class = "grid-padrao" })
.ClientEvents(events => events
.OnDataBound("atualizarCss")
.OnRowSelect("selecionarRegistro")
)
.Columns(columns =>
{
columns.Bound("Descricao").Title("Descrição");
columns.Bound("Handle").Title("Código");
})
.Pageable()
.Sortable()
)
I think you have a conflic somewhere in your View. Here something you can do to find your problem:
Create a View that will only show your _GridPesquisaLookup.cshtml without any ajax. That way, you will be able to test ONLY this grid. Use Html.Partial("_GridPesquisaLookup") in your View.
If the grid work, its because there's a conflic with the other View when you use two grids at the same time. Maybe the two grids have the same name. It happened to me a few months ago and i had the same problem as you.
If the grid does'nt work, well you will know that your problem is from this grid. You will have to do more tests.
精彩评论