DevExpress MVC GridView - How to get cell click event

前端 未结 1 965
情深已故
情深已故 2020-12-16 21:59

Using DevExpress\'s GridView, I would like to trigger a (clientside) event when a cell is selected (or simply clicked on).

There already is a way to get the click ev

相关标签:
1条回答
  • 2020-12-16 22:36

    It is possible to attach the required client-side handler for an individual DataCell by handling the GridViewSettings.HtmlDataCellPrepared event:

    function OnCellClick(visibleIndex, fieldName) {
        alert(visibleIndex + " " + fieldName);
    }
    
    
    @Html.DevExpress().GridView(settings => {
        ...
        settings.HtmlDataCellPrepared = (sender, e) => {
            e.Cell.Attributes.Add(
                "onclick",
                string.Format("OnCellClick('{0}', '{1}');", e.VisibleIndex, e.DataColumn.FieldName)
            );
        };
    
    }).Bind(Model).GetHtml()
    
    0 讨论(0)
提交回复
热议问题