DevEx preSS MVC GridView控件 - 如何获得细胞click事件 [英] DevExpress MVC GridView - How to get cell click event

查看:498
本文介绍了DevEx preSS MVC GridView控件 - 如何获得细胞click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用DevEx preSS的GridView控件,我想触发(客户方)事件当选择一个单元格(或简单点击)。

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

有已经是方式来获得一整行的click事件,但是没有摆弄周围也没有文件给我任何线索如何实现这一目标的细胞。

There already is a way to get the click events for an entire row, but neither fiddling around nor the documentation gives me any clue how to achieve this for cells.

这是我的行:

Html.DevExpress().GridView(settings =>
{
    // removed a lot of code here
    settings.ClientSideEvents.RowDblClick = "OnGridRowDblClick";
}).Bind(Model).GetHtml()

这将导致javascript函数 OnGridRowDblClick 当行被双击被调用。理想情况下,应该是这样

Which will cause the javascript function OnGridRowDblClick to be called when a row is double clicked. Ideally there should be something like

settings.ClientSideEvents.CellClick =OnCellClick;

不过,这并不存在,我也不能找到任何实现这一目标。我被分配到修改外部开发的网站,在这里,没有人有使用DevEx preSS的经验。请赐教,谢谢!

However, this does not exist, nor can I find anything to achieve this. I have been assigned to modify an externally developed website, and no one here has any experience using DevExpress. Please enlighten me, thanks!

推荐答案

有可能通过处理 GridViewSettings.HtmlDataCell prepared 事件附加单个DATACELL所需的客户端处理程序

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()

这篇关于DevEx preSS MVC GridView控件 - 如何获得细胞click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆