We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hyperlink column/cell with values from another cell

Thread ID:

Created:

Updated:

Platform:

Replies:

104919 Aug 28,2012 02:17 PM UTC Aug 30,2012 09:46 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Steffen
Asked On August 28, 2012 02:17 PM UTC

Hi there,

i wonder if it's possible to format a (bound!) cell value as hyperlink with values from another cell (same row).

Let's assume i've a user model in place containing a "Name" and a "UserId" property. What i#d like to achieve is something like this:

[...]
(c => c.Name).Format("<a rel='nofollow' href=\"User/UserSummary?userId={UserId}\">{Name}</a>");
The value (for sorting/grouping etc.) should use the "Name" but for link it supposed to be formated with the values of "UserId". Unfornately this approach gives me an "Input string was not in a correct format." FormatException.

It seems that the GridRender "forgets" the values of the row for a bound column and only uses the cell itself, while the format for an unbound column is capable of using the row values.

Is there any way to achieve a hyperlinked column for bound columns with values from another cell/column to pass within the link?

Thanks in advance!

Steffen

Ranjithkumar R G [Syncfusion]
Replied On August 30, 2012 09:46 AM UTC

Hi Steffen,

Thanks for using Syncfusion products.

We suggest you to handle QueryCellInfo to achieve your requirement. Please refer to the code snippet below to achieve this.

[ASPX]

  @( Html.Syncfusion().Grid<Sample.Models.JSONOrder>('SampleGrid')
                .Datasource(Model)
                .Caption('Orders')
                .QueryCellInfo(
                cell => Html.RenderAction('onQueryCellAction''Home'new { args = cell })
                ) 
  )

[Controller]

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(PagingParams args)
        {
            IEnumerable data = GridOrders;
            var engine = data.GridActions<JSONOrder>() as GridHtmlActionResult<JSONOrder>;
            engine.GridModel.QueryCellInfo = onQueryCellAction;
            return engine;
 
 
        }
 
        public void onQueryCellAction(GridTableCell<JSONOrder> args)
        {
            if (args.TableCellType == GridTableCellType.RecordFieldCell || args.TableCellType == GridTableCellType.AlternateRecordFieldCell)
            {
                if (args.Column.MappingName == 'EmployeeID')
                {
                    args.Text = '<a class='TemplateCell' rel='nofollow' href='Home/Load?id='+args.Data.OrderID+''>' + args.Data.EmployeeID + '</a>';
                }
            }
        }

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

Sample.zip       

Please let me know if you have any concern.

Regards,

Ranjithkumar


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;