- Home
- Forum
- ASP.NET MVC
- Hyperlink to column content in grid
Hyperlink to column content in grid
Hello
i have grid as follow.
View:
@(Html.EJ().Grid<object>("RecentlyViewedAccounts")
.Datasource((System.Data.DataTable)ViewBag.vieweddatasource)
.AllowSorting()
.AllowResizing()
.EnableRowHover(true)
.Columns(col =>
{
col.Field("currentUserId").HeaderText("User").Add();
col.Field("AccountGroupName").HeaderText("Account Name").Add();
col.Field("VisitedDate").HeaderText("Visited Date").TextAlign(TextAlign.Center).Format("{0:MM/dd/yyyy}").Width(100).Add();
}))
Thanks for contacting Syncfusion support.
Your requirement has been achieved by using columnTemplate property of the ejGrid. A Column template is used to render a specific template to a particular column using Template and TemplateID property. In this template, we can render the images or checkboxes or any html elements to the column. So, using the column template we can render the hyperlink content for the particular column.
Please find the code example and sample:
|
@(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowSorting() .AllowFiltering() .ClientSideEvents(eve => eve.RecordClick("recordclick")) .Columns(col => { col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.HeaderText("Employee Image").Template(true).TemplateID("#columnTemplate").TextAlign(TextAlign.Center).Field("LastName").Width(110).Add(); col.Field("FirstName").HeaderText("First Name").Width(100).Add(); col.Field("Title").Width(120).Add(); col.Field("City").Width(100).Add(); col.Field("Country").Width(100).Add(); }) ) <script type="text/x-jsrender" id="columnTemplate"> <a rel='nofollow' href="http://www.syncfusion.com/">{{:LastName}}</a> </script>
|
Sample: http://www.syncfusion.com/downloads/support/forum/120860/ze/Sample145862_(2)704426861
Refer to the Help document for the Column Template API.
ColumnTemplate: http://help.syncfusion.com/aspnetmvc/grid/columns#template
We also created a KB documentation to place hyperlink in the grid columns. Please find the documentation from the following link
http://www.syncfusion.com/kb/3767/how-to-place-hyperlink-in-grid-column
Query : “where the account group name is updated for every visit”
While clicking the hyperlink content, you want a post to the controller with the selected records. If not, could you please elaborate the requirement, it will be helpful to provide a better solution.
Regards,
Prasanna Kumar N.S.V
- Complete grid rendering code zipped
- Version details
- Screenshot of error if any
- 3 Replies
- 4 Participants
-
GD Gajanan Deshpande
- Oct 23, 2015 08:42 AM UTC
- Jan 13, 2020 10:41 AM UTC