This is a migrated thread and some comments may be shown as answers.

Grid Sorting Problem

1 Answer 54 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
ICZ asked on 11 Jan 2013, 11:37 AM
In my MVC 4  application I'm using Kendo UI Grid. For data binding I'm using Ajax
Code in view look like this:

Html.Kendo().Grid(new DataTable())
    .Columns(columns =>
            columns.Bound("Code").Title("Kod").Width(30).HeaderHtmlAttributes(new {title = "Kod klienta"}).ClientTemplate("# if (Code === 'A') { # <img title='Our client' src='" + @Url.Content("~/Content/Images/ico_16x16_our.png") + "' # } #");                            
            columns.Bound("Name").Title("Jmeno").Width(55).HeaderHtmlAttributes(new {title = "Jmeno klienta"});
            columns.Bound("Surname").Title("Prijmeni").Width(60).HeaderHtmlAttributes(new {title = "Prijmeni klienta"});                            
            columns.Template(@<text></text>).ClientTemplate("<div class='actions'><a id='link_client_#=ClientId#' href='" + Url.Action("Prehled", "Klient") + "/#=ClientId#?nadorId=#'>Detail</a></div>").Width(150);
    .DataSource(dataBinding => dataBinding
                                   .Read("DataGrid", "Zaznamy", Model.Filter)
                                   .Model(model => model.Id("Id")))
    .Pageable(paging =>
              paging.PageSizes(new[] {20, 50, 100, 200, 500, 1000}))
    .Scrollable(c => c.Height("600px"))
    .Resizable(resizing => resizing.Columns(true))
    .Events(events => events.DataBound("onDataBound"))

Action in Controler look like this:

  public ActionResult DataGrid(GridCommand command)
      model.Data = load ...   
      return Json(new DataSourceResult {Data = model.Data, Total = model.TotalCount}, JsonRequestBehavior.AllowGet);

The broblem is when I click on column header, binding action is called, but then I'm redirected to that action bz get.
That's why in header is generated:

<a class="k-link" href="/Zaznamy/DataGrid?IsEmpty=False&RodneCislo=60&UseLast=False&Filter.RodneCislo=60&_submit=None&grid-zaznamy-sort=KrajOkres-asc">

I dont know how to suppress that contet of href. In all samples which I have ever seen was #

1 Answer, 1 is accepted

Sort by
Vladimir Iliev
Telerik team
answered on 15 Jan 2013, 06:38 AM
Hi Ladislav,

Most probably this behavior is caused by missing/invalid/not loaded correctly jQuery or KendoUI scripts in the project. For more information about required scripts (which must be loaded before the Grid code) please check the JavaScirpt Dependencies article. 

For current configuration I would suggest including the scripts below:

  • jquery.min.js v.1.8.2
  • kendo.all.min.js v.2012.3.1114
  • kendo.aspnetmvc.min.js v.2012.3.1114

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question