-
Notifications
You must be signed in to change notification settings - Fork 1
/
Server-side.aspx.cs
24 lines (23 loc) · 1.39 KB
/
Server-side.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using DevExpress.Web;
using System.Linq;
using System.Web.UI;
public partial class ServerSide : Page {
protected void Grid_FillContextMenuItems(object sender, ASPxGridViewContextMenuEventArgs e) {
if (e.MenuType == GridViewContextMenuType.Rows) {
e.Items.Clear();
e.Items.Add(e.CreateItem("Custom item for all rows", "AllRows"));
e.Items.Add(e.CreateItem("Custom item for selected rows only", "OnlySelectedRows"));
e.Items.Add(e.CreateItem("Custom item for selected rows with 'Discontinued=true' only", "OnlySelectedAndDiscontinuedRows"));
}
}
protected void Grid_ContextMenuItemVisibility(object sender, ASPxGridViewContextMenuItemVisibilityEventArgs e) {
if (e.MenuType == GridViewContextMenuType.Rows) {
GridViewContextMenuItem menuItemSelected = e.Items.Find(item => item.Name == "OnlySelectedRows") as GridViewContextMenuItem;
GridViewContextMenuItem menuItemSelectedAndDiscontinued = e.Items.Find(item => item.Name == "OnlySelectedAndDiscontinuedRows") as GridViewContextMenuItem;
for (int i = 0; i < Grid.VisibleRowCount; i++) {
e.SetVisible(menuItemSelected, i, Grid.Selection.IsRowSelected(i));
e.SetEnabled(menuItemSelectedAndDiscontinued, i, Grid.Selection.IsRowSelected(i) && (bool)Grid.GetRowValues(i, "Discontinued"));
}
}
}
}