Using a Telerik Grid with ASP.NET MVC 3 Razor engine.
When a user selects a row, we un-hide some part of the page. This is working fine when I click on a row.
However, I need to automatically select the first row when the page is loaded
I can change the row display color so it appears selected, but I can’t figure out how to have the select event called!
Here is the grid code :
@(Html.Telerik().Grid<SomethingViewModel>()
.Name("SomethingGroupGrid")
.ClientEvents(events =>
{
events.OnDataBinding("SomethingGroupGrid_onDataBinding");
})
.DataBinding(dataBingding => dataBingding.Ajax().Select("SomethingGroupGrid", "Something"))
.Columns(columns =>
{
columns.Bound(c => c.Id).Hidden();
columns.Bound(c => c.Name)
.Title("Groups");
})
.Selectable()
.Pageable(x => x.PageSize(10))
.ClientEvents(events => events.OnRowSelect("SomethingGroupGrid_RowSelect"))
)
Can someone help?
Ok I found a freakishly ugly solution :
I added a OnRowDataBound event on the grid. This OnRowDatabound Functions fires the OnRowSelect events.
Then I added page global javascript variable to hold a bool value that checks if the first row has been selected, so the OnRowDatabound does not call OnRowSelect for each row.
Plese tell me that there is a better way to do that, or it will severely degrade my opinion of Telerik controls (which is already damn low).