【问题标题】:Get index on row deleting (devexpress ASPxGridView )获取行删除索引(devexpress ASPxGridView)
【发布时间】:2014-10-13 15:11:09
【问题描述】:

今天我尝试在单击CommandColumnCustomButton 删除按钮时获取当前索引。我有一个在运行时填充了一些值的 GridView,下面是我如何为此控件的每一行添加“删除”按钮:

GridViewCommandColumn cmdCol = new GridViewCommandColumn();
cmdCol.Caption = "Edition";
GridViewCommandColumnCustomButton cDelBtn = new GridViewCommandColumnCustomButton();

cDelBtn.ID = "supprimer";
cDelBtn.Text = "supprimer";

cDelBtn.Visibility = GridViewCustomButtonVisibility.AllDataRows;           

cmdCol.CustomButtons.Add(cDelBtn);
gridView_test.Columns.Add(cmdCol);

它只是创建一个列,在每一行都有一个允许删除该行的按钮。

在上面代码的最后一行之后,我添加了一行,可以精确地在单击那些“删除”按钮时执行某些操作。这是执行此操作的代码:

gridView_test.ClientSideEvents.CustomButtonClick = "function (s, e) { alert( e.FocusedRowIndex ); }";

该函数有两个参数(类似于 ASP 中的事件处理程序基本函数):s 是“发送者”,代表对象(这里是“删除”按钮),e 是“事件”。我试图捕捉事件的当前索引,但它不起作用,显示我“未定义”。

请看下面我想实现的工作流程示例:

PRICE  |   Edit
  5    |  delete
  18   |  delete

我想,当单击第二行的“删除”按钮时,显示“1”,这是代表 GridView 的数组的索引(因为您知道数组从索引 0 开始...... )。

有些人知道我怎样才能在下面我的函数的 javascript 部分中做到这一点?或者也许存在替代方案?

更多信息: DevExpress 版本:14.1 控制:ASPxGridView IDE:Visual Studio 2013 语言:ASP.net WebForms

【问题讨论】:

  • 代替alert(e.FocusedRowIndex),使用console.log(e),查看e的对象结构,使用write属性。

标签: javascript c# asp.net gridview


【解决方案1】:

发现我的错误,这不是我使用的正确属性。更好地使用“visibleIndex”属性:

e.visibleIndex

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多