I have a situation where I have to disable the selectable property of the grid. And I have to get row values when I clicked a specific column. With selection enabled this working great. How can I get row values when selection is disabled?

Here is my code...

@(Html.Kendo().Grid<Portal.Presentation.Web.Planning.MVC.Areas.Razor.Models.LongTermPlanModel>()
          .Name("LtGrid")
          .Events(e => e.DataBound("LongTermHandler.onLtMainGridDataBound"))
          .Columns(columns =>
          {

              columns.Bound(x => x.CategoryName);
              columns.Bound(x => x.Group).HtmlAttributes(new { id = "btnGrp" }); 
          }) 
 .Pageable(x => x.PageSizes(new[] { 10, 20, 30, 40 })
                             .Refresh(true))
          .Sortable()
         // I 've commented the selectable property
         //.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
          .ClientDetailTemplateId("client-template2")
          .HtmlAttributes(new { style = "height:auto;" })
          .Groupable()
          .AutoBind(false)
          .DataSource(dataSource => dataSource
                                        .Ajax()
                                        .Model(model =>
                                        {
                                            model.Id("Code");
                                        })
                                        .PageSize(10)
                                        .Read(read => read.Action("LtGridRead", "ControllerName").Type(HttpVerbs.Post))
          )
          )
}

javascript code

$("#LtGrid").on("click", "#btnGrp", function (e) {
                debugger;
                e.preventDefault();

                var gview = $("#LtGrid").data("kendoGrid");
               // Below line is not working...
                var selectedItem = gview.dataItem(gview.select());

                if (selectedItem && selectedItem.ProductGroup) {
                    var eventUrl = '@Url.Action("MethodName", "ControllerName")';
                    $.ajax({
                        url: eventUrl,
                        data: {

                            season: selectedItem.SeasonName,
                            productGroup: selectedItem.Group,
                            category: selectedItem.CategoryName
                        },
                        dataType: "JSON",
                        type: "POST",
                        success: function (result) {
                            window.open("@Url.Action("../PageName")", 'mywindowrmlt');
                        }
                    });
                    }
            });

Related posts

Recent Viewed