This question is locked. New answers and comments are not allowed.
Is it possible to make a grid send the user's browser to another page when they click (select) a row? What I mean is that the user sees a normal, read-only grid of data. As they click on a row the browser acts like a link has been clicked and goes to the details view page for that record.
In previous projects with older versions of the MVC Grid (before any "select" functionality was added) I've done this completely by hand, including all the nice rollover highlighting and other features that are now part of the Grid. I was excited to finally play with the new features in the latest version, but I can't find a way to avoid doing a few things by hand. Here's what I have (working):
This works and isn't very long, but I was sort of expecting I wouldn't have to write any Javascript to make this happen (what's above looks short, but it's missing error-checking and other code that will triple the size of the script section). Also it's missing the CSS that uses the "hand" cursor when the user puts the cursor over the row (that's important so the user knows the row is a clickable "link").
If what I have above is as good as it gets, then please consider this a polite feature suggestion :)
Thanks!
In previous projects with older versions of the MVC Grid (before any "select" functionality was added) I've done this completely by hand, including all the nice rollover highlighting and other features that are now part of the Grid. I was excited to finally play with the new features in the latest version, but I can't find a way to avoid doing a few things by hand. Here's what I have (working):
@(Html.Telerik().Grid<
SystemDataViewModel
>()
.Name("SystemData")
.Columns(c =>
{
c.Bound(s => s.ID).Hidden(true);
c.Bound(s => s.Value);
c.Bound(s => s.SortOrder);
c.Bound(s => s.ParentDatumID);
c.Bound(s => s.IsActive);
})
.PrefixUrlParameters(false)
.DataBinding(b => b.Ajax().Select("UpdateIndexGrid", "SystemData",
((QuickFilterModel)ViewBag.QuickFilterModel).GetRouteValues()))
.HtmlAttributes(new { Class = "NonAjaxSelectionGrid QuickFilterGrid" })
.ClientEvents(e => e.OnRowSelected("OnRowSelected"))
.Reorderable(r => r.Columns(true))
.Resizable(r => r.Columns(true))
.Selectable()
.Sortable()
.Pageable(p => p.Style(GridPagerStyles.NextPreviousAndNumeric | GridPagerStyles.PageInput | GridPagerStyles.Status)))
@(Html.ActionLink("hidden-View", "Details", "SystemData", new { id = "0" }, new { id = "hiddenViewGridLink", style = "display:none;" }))
<
script
type
=
"text/javascript"
>
function OnRowSelected(e) {
var rowID = e.row.cells[0].innerHTML;
var link = $("#hiddenViewGridLink");
window.location.href = (link[0].href + rowID);
}
</
script
>
This works and isn't very long, but I was sort of expecting I wouldn't have to write any Javascript to make this happen (what's above looks short, but it's missing error-checking and other code that will triple the size of the script section). Also it's missing the CSS that uses the "hand" cursor when the user puts the cursor over the row (that's important so the user knows the row is a clickable "link").
If what I have above is as good as it gets, then please consider this a polite feature suggestion :)
Thanks!