Hi,
I need to add hyperlinks on the data that I am displaying in iggrid.
I have this code and it's not working.
@(Html.Infragistics().Grid(Model).ID("grid3") .Columns(column => { column.For(x => x.Id).DataType("string").Template("${Id}").HeaderText("Customer ID"); column.For(x => x.ProductName).DataType("string").HeaderText("Name"); column.For(x => x.CategoryID).DataType("string").HeaderText("Cat"); column.For(x => x.SupplierID).DataType("string").HeaderText("sup"); }) .Features(features => { features.Paging().VisiblePageCount(5).ShowPageSizeDropDown(true).PageSize(10).PrevPageLabelText("Previous").NextPageLabelText("Next"); features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("Id").AllowSorting(true); }); }) .Width("100%") .Height("350px") .DataBind() .Render() )
What am I doing wrong?
Thanks.
Hello Jessica,
Thank you for posting in our forums.
Are you trying to add hyperlinks in "ID" column?
You are on the right way using the template.
Just need to add the hyperlink :
{ headerText: "Product Name", key: "Name", dataType: "string", template:"<a href='www.google.com/search > ${Name} </a>" }
OR in the chaining as is your case :
column.For(x => x.Id).DataType("string").Template("<a href='www.google.com/search ${Id} </a>" ).HeaderText("Customer ID");
You can take a look at the help documentation and samples:
https://www.igniteui.com/help/iggrid-column-template
https://www.igniteui.com/grid/column-template
Hope this helps.
Thanks for answering!
I tried to use that code
@(Html.Infragistics().Grid(Model).ID("grid3") .Columns(column => { column.For(x => x.Id).DataType("string").Template("<a href='http://www.google.com/search?q=${Id}'> ${Id} </a>").HeaderText("Customer ID"); column.For(x => x.ProductName).DataType("string").HeaderText("Name"); column.For(x => x.CategoryID).DataType("string").HeaderText("Cat"); column.For(x => x.SupplierID).DataType("string").HeaderText("sup"); }) .Features(features => { features.Paging().VisiblePageCount(5).ShowPageSizeDropDown(true).PageSize(10).PrevPageLabelText("Previous").NextPageLabelText("Next"); features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("Id").AllowSorting(true); }); }) .Width("100%") .Height("350px") .DataBind() .Render() )
But it still won't put hyperlinks on my data id's
I want the Id's to be links to another page.