I have a kendo grid in my project and a custom button in that grid. I tried to get row data when I click the button. But javascript code gives me error which is:
"Javascript runtime error: Unable to get property "dataItem" of undefined or null referance"
My grid code :
@model IEnumerable<SalePortal.ServiceReference.Product>
@{
ViewBag.Title = "GetProduct";
}
@(Html.Kendo().Grid<SalePortal.ServiceReference.Product>()
.Name("Grid")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetProduct", "Home"))
)
.Columns(columns =>
{
columns.Bound(product => product.pID);
columns.Bound(product => product.productName);
columns.Bound(product => product.productPrice);
columns.Command(command => command.Custom("Buy").Click("Sale"));
})
)
My javascript code :
<script type="text/javascript">
function Sale() {
var gridE = $("#kendoo").data("kendoGrid");
var selectedItem = gridE.dataItem(gridE.select()); //Error here!!!
alert(selectedItem);
</script>