ASPX
<dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="ObjectDataSource1" KeyFieldName="Key"
ClientInstanceName="grid" Width="100%" OnCustomButtonCallback="ASPxGrid1_CustomButtonCallback">
<ClientSideEvents CustomButtonClick="onGrid1ButtonClick" />
<Columns>
<dx:GridViewCommandColumn Caption="自定义操作">
<CustomButtons>
<dx:GridViewCommandColumnCustomButton ID="Button1" Text="审核通过" />
<dx:GridViewCommandColumnCustomButton ID="Button2" Text="审核不通过" />
<dx:GridViewCommandColumnCustomButton ID="Button3" Text="删除" />
</CustomButtons>
</dx:GridViewCommandColumn>
</Columns>
</dx:ASPxGridView>
C#
protected void ASPxGridView1_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e)
{
if (e.ButtonID == "Button1")
{
// 按钮1方法
} if (e.ButtonID == "Button2")
{
// 按钮2方法
} if (e.ButtonID == "Button3")
{
// 按钮3方法
} }
JS
function onGrid1ButtonClick(s, e) { switch (e.buttonID) {
case "Button1":
// 用于操作前确认
if (confirm("确定要执行这个操作么?"))
e.processOnServer = true;
break; case "Button2":
// 可以定义相关事件
if (someEvent) // 或者 !typeof(someEvent) === 'undefined'
someEvent.call();
//someEvent.apply(context, arguments); 可以传入指定的context break; case "Button3": break;
default: break;
}
}