Hello,
I am wondering how I can get the total rowcount while inside the ondatabound event ?
Here is the background of why I am looking for this info. I am trying to code in a row cap lets say of 250 records which will be done in the controller. However I have a requirement that if the query was capped I need to offer the user an option to view all the rows. Basically implementing an alert to the user that they ran a query that returns a large set of data. At first they will only get the 250 rows but they are given an option to return all rows like a button or something which would rebind the grid and grab all rows from the controller.
I am sending a parameter in the Action call to bind that specifies whether or not to show all records, but I need to figure out how to get a row count so I know if the initial databind hit the cap.
Here is my code:
I am wondering how I can get the total rowcount while inside the ondatabound event ?
Here is the background of why I am looking for this info. I am trying to code in a row cap lets say of 250 records which will be done in the controller. However I have a requirement that if the query was capped I need to offer the user an option to view all the rows. Basically implementing an alert to the user that they ran a query that returns a large set of data. At first they will only get the 250 rows but they are given an option to return all rows like a button or something which would rebind the grid and grab all rows from the controller.
I am sending a parameter in the Action call to bind that specifies whether or not to show all records, but I need to figure out how to get a row count so I know if the initial databind hit the cap.
Here is my code:
@(Html.Kendo().Grid(Model)
.Name("Grid")
.HtmlAttributes(new { style = "font-size:.85em;" })
.Columns(columns =>
{
columns.Bound(p => p.Id).Width(60);
columns.Bound(p => p.Title).Width(250);
columns.Bound(p => p.AssignedUser).Width(120);
})
.Pageable()
.Groupable()
.Sortable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.Contains("Contains")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")))
)
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Get", "Grid", new {showAll = ViewBag.ShowAll}))
)
.Events(e => e.Change("onChanged").DataBound("onDataBound"))
)