External Hyperlink In Cell

Hello, 
Is it possible to create a hyperlink to a website inside of a grid cell in Essential Grid for Asp.net MVC?  The actual url of the link will be based off of the data bound from the table's data source.

1 Reply

BM Bala Murugan A.S Syncfusion Team May 23, 2012 05:16 AM UTC

Hi Kenneth Lam,

Thanks for using Syncfusion Products

Your requirement of having hyperlink in a column can be achieved by handling QueryCellInfo event. We must handle QueryCellInfo event during paging action also. Please refer to the code-snippet below.

[ASPX]

<%=Html.Syncfusion().Grid<hyperlink.Models.Order>("FlatGrid")
.Datasource(Model)
.EnablePaging()
.EnableSorting()


.QueryCellInfo(
cell => Html.RenderAction("onQueryCellAction", "Home", new { args = cell })
)

%>



[Controller-CS]

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(PagingParams args)
{

IEnumerable data = new NorthwindDataContext().Orders.Take(200);
var engine = data.GridActions<Order>() as GridHtmlActionResult<Order>;
engine.GridModel.QueryCellInfo = onQueryCellAction;
return engine;
}


public void onQueryCellAction(GridTableCell<Order> args)
{
if (args.TableCellType == GridTableCellType.RecordFieldCell || args.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (args.Column.MappingName == "ShipCountry")
{
args.Text = "" + args.Data.ShipCountry + "";

}
}
}


Please refer to the below link to download the sample application.

Sample: http://www.syncfusion.com/downloads/Support/DirectTrac/94716/HyperLink-38769460.zip

Please let me know if you have any concern.

Regards,
Bala Murugan A.S


Loader.
Up arrow icon