Hyperlink column/cell with values from another cell

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

1 Reply

RR Ranjithkumar R G Syncfusion Team 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


Loader.
Up arrow icon