Declined
Last Updated: 25 Sep 2026 14:55 by ADMIN
Phạm
Created on: 06 Aug 2024 10:14
Category: UI for ASP.NET MVC
Type: Bug Report
0
Cannot pass parameter into function binding to a column in grid
I have a grid like this:

@(Html.Kendo().Grid<VIP_Logic.Models.Dashboard.CriteriaModel>().Name("dgdCriteria")
                  .Columns(column =>
                  {
                      column.Bound(b => b.ParamIndex).Title("No.").Width(40);
                      column.ForeignKey(b => b.ColumnName, (IEnumerable<SelectListItem>)ViewBag.LstColumnNames, "value", "text").HtmlAttributes(new { style = "text-align: left", onChange = "onChangeColumn('#=ParamIndex#');" }).Title("Column").Width(100);
                      column.ForeignKey(b => b.Operator, (IEnumerable<SelectListItem>)ViewBag.LstOperators, "value", "text").HtmlAttributes(new { style = "text-align: left", onChange = "onChangeOperator('#=ParamIndex#');" }).Title("Operator").Width(100);
                      column.Bound(b => b.ParamValue).HtmlAttributes(new { style = "text-align: left", onChange = "setCriteriaXml();" }).Title("Value").Width(150).Encoded(false);
                      column.Bound(b => b.ParamIndex).ClientTemplate("<button class= 'k-button' type='button' onclick=onRemoveCriteria('#=ParamIndex#')>" + "Remove" + "</button>").HtmlAttributes(new { style = "text-align: center" }).Title(string.Empty).Width(50);
                  })

All the function in onchange attribute required a parameter ParamIndex. In old version, the syntax "#=ParamIndex#'" still work fine, but since i upgrade Kendo UI to latest version, this syntax doesn't work anymore. How can i make it work like old version?
1 comment
ADMIN
Rumen
Posted on: 25 Sep 2026 14:55

Hi Phạm,

new

The reported behavior is expected. Starting with the R2 2023 release, Grid column HTML attributes are no longer processed as Kendo UI templates. Therefore, the legacy #=ParamIndex# syntax is not evaluated inside HtmlAttributes.

Use the function-based column attributes handler instead:

column.ForeignKey(...)
    .HtmlAttributes("columnAttributes");
function columnAttributes(dataItem) {
    return {
        style: "text-align: left",
        onchange: "onChangeColumn('" + dataItem.ParamIndex + "');"
    };
}

The handler receives the current data item and returns the attributes that will be applied to the Grid cell.

For more information, see the documentation for Grid column attributes and the MVC HtmlAttributes(string) overload.

We are closing this item as by design.

Regards,
Rumen
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.