add a grid to a view
open the view with data bound to the grid.
First line of data is not selected.
Now i have to program the ondatabound property for a function which belongs to the grid component. Make it configurable for grids which do not need this feature or vice versa.
Hi, Ron,
From my experience, I believe that the requirement to select a row on load is not always the same - i.e. it is not always the first row that others want selected.
In my opinion, it would be more flexible to have a property that accepts a selector so that way if using multiple select, you could use it, too. What do you think about something like:
// single selection
GridBuilder.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).SelectOnLoad("tr:eq(0)")
// OR
GridBuilder.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).SelectOnLoad(".some-class-name")
// multiple selection
GridBuilder.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).SelectOnLoad("tr:eq(0), tr:eq(3)")
Look forward to hearing back from you.
Kind Regards,
Alex Hajigeorgieva
Progress Telerik
I have something like this in mind:
GridBuilder.Selectable(selectable => selectable.Mode(GridSelectionMode.Single).SelectFirstRow(true)
I prefer this property to have a default value of true, so that it only needs to be set in case of the rare occasion that it needs to be false.
kind Regards,
Ron Baeten
senior developer
TNG Screen
Hi, Ron,
Dependent on the desired selection (cell or row), you can achieve that by adding the "k-state-selected" class to the column or to the row conditionally.
For the row, you can implement a ClientRowTemplate like this:
.Columns(columns =>
{
columns.Bound(p => p.OrderID);
})
.ClientRowTemplate("<tr data-uid='#: uid #' class='#=OrderID %2 == 0 ? 'k-state-selected': ''#'>" +
"<td class='details'> #: OrderID # </td>" +
"</tr>")
The cell configuration on the other hand would look like this:
columns.Bound(p => p.OrderID).HtmlAttributes(new { @class = "#=OrderID %2 == 0 ? 'k-state-selected': ''#"});
In case you had something else in mind, can you please advise how you imagine its implementation and functionality, for instance what would pseudo code for it look like?
Kind Regards,
Alex Hajigeorgieva
Progress Telerik