|
61 | 61 | void Grid_CustomizeContextMenu(GridCustomizeContextMenuEventArgs args) { |
62 | 62 | if (args.Context is GridDataRowCommandContext rowContext) { |
63 | 63 | if (rowContext.Grid.IsEditing()) { |
64 | | - var save = args.Items.AddCustomItem("Save", async () => { |
| 64 | + var saveEdit = args.Items.AddCustomItem("Save", async () => { |
65 | 65 | rowContext.Grid.BeginUpdate(); |
66 | 66 | await rowContext.Grid.SaveChangesAsync(); |
67 | 67 | rowContext.Grid.EndUpdate(); |
68 | 68 | }); |
69 | | - args.Items.AddCustomItem("Cancel", async () => { |
| 69 | + saveEdit.IconCssClass = "grid-context-menu-item-edit-row"; |
| 70 | + |
| 71 | + var cancelEdit = args.Items.AddCustomItem("Cancel", async () => { |
70 | 72 | rowContext.Grid.BeginUpdate(); |
71 | 73 | await rowContext.Grid.CancelEditAsync(); |
72 | 74 | rowContext.Grid.EndUpdate(); |
73 | 75 | }); |
| 76 | + cancelEdit.IconCssClass = "grid-context-menu-item-delete-row"; |
74 | 77 | } |
75 | | - args.Items.AddCustomItem("New", async () => { |
| 78 | + var newRow = args.Items.AddCustomItem("New", async () => { |
76 | 79 | rowContext.Grid.BeginUpdate(); |
77 | 80 | await rowContext.Grid.StartEditNewRowAsync(); |
78 | 81 | rowContext.Grid.EndUpdate(); |
79 | | - }).BeginGroup = true; |
80 | | - args.Items.AddCustomItem("Edit", async () => { |
| 82 | + }); |
| 83 | + newRow.IconCssClass = "grid-context-menu-item-new-row"; |
| 84 | + newRow.BeginGroup = true; |
| 85 | + |
| 86 | + var editRow = args.Items.AddCustomItem("Edit", async () => { |
81 | 87 | rowContext.Grid.BeginUpdate(); |
82 | 88 | await rowContext.Grid.StartEditRowAsync(rowContext.RowVisibleIndex); |
83 | 89 | rowContext.Grid.EndUpdate(); |
84 | 90 | }); |
85 | | - args.Items.AddCustomItem("Delete", async () => { |
| 91 | + editRow.IconCssClass = "grid-context-menu-item-edit-row"; |
| 92 | + |
| 93 | + var deleteRow = args.Items.AddCustomItem("Delete", () => { |
86 | 94 | rowContext.Grid.BeginUpdate(); |
87 | 95 | rowContext.Grid.ShowRowDeleteConfirmation(rowContext.RowVisibleIndex); |
88 | 96 | rowContext.Grid.EndUpdate(); |
89 | 97 | }); |
| 98 | + deleteRow.IconCssClass = "grid-context-menu-item-delete-row"; |
90 | 99 | } |
91 | 100 |
|
92 | 101 | if (args.Context is GridHeaderCommandContext headerContext) { |
93 | 102 | var isFilterRowVisible = headerContext.Grid.ShowFilterRow != false; |
94 | | - string filterRowItemText = isFilterRowVisible ? "Hide Filter Row" : "Show Filter Row"; |
95 | 103 | var newFilterRowState = isFilterRowVisible ? false : true; |
96 | | - args.Items.AddCustomItem(filterRowItemText, () => { |
| 104 | + var filterRow = args.Items.AddCustomItem("Filter Row", () => { |
97 | 105 | headerContext.Grid.BeginUpdate(); |
98 | 106 | headerContext.Grid.ShowFilterRow = newFilterRowState; |
99 | 107 | headerContext.Grid.EndUpdate(); |
100 | 108 | }); |
| 109 | + filterRow.IconCssClass = "grid-context-menu-item-filter-row"; |
| 110 | + filterRow.CssClass = isFilterRowVisible ? "menu-item-selected" : ""; |
101 | 111 |
|
102 | 112 | var isFiltered = headerContext.Grid.GetFilterCriteria() != null; |
103 | | - args.Items.AddCustomItem("Clear Filter", () => { |
| 113 | + var clearFilter = args.Items.AddCustomItem("Clear Filter", () => { |
104 | 114 | headerContext.Grid.BeginUpdate(); |
105 | 115 | headerContext.Grid.ClearFilter(); |
106 | 116 | headerContext.Grid.EndUpdate(); |
107 | | - }).Enabled = isFiltered ? true : false; |
| 117 | + }); |
| 118 | + clearFilter.IconCssClass = "grid-context-menu-item-clear-filter"; |
| 119 | + clearFilter.Enabled = isFiltered ? true : false; |
| 120 | + |
| 121 | + var isFooterVisible = headerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Always |
| 122 | + || headerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Auto && headerContext.Grid.GetTotalSummaryItems().Count > 0; |
| 123 | + var newFooterState = isFooterVisible ? GridFooterDisplayMode.Never : GridFooterDisplayMode.Always; |
| 124 | + var footer = args.Items.AddCustomItem("Footer", () => |
| 125 | + { |
| 126 | + headerContext.Grid.BeginUpdate(); |
| 127 | + headerContext.Grid.FooterDisplayMode = newFooterState; |
| 128 | + headerContext.Grid.EndUpdate(); |
| 129 | + }); |
| 130 | + footer.IconCssClass = "grid-context-menu-item-footer"; |
| 131 | + footer.CssClass = isFooterVisible ? "menu-item-selected" : ""; |
108 | 132 |
|
109 | | - args.Items.AddCustomItem("Fix Column to the Left", () => { |
| 133 | + var fixLeft = args.Items.AddCustomItem("Fix Column to the Left", () => { |
110 | 134 | headerContext.Grid.BeginUpdate(); |
111 | 135 | headerContext.Column.FixedPosition = GridColumnFixedPosition.Left; |
112 | 136 | headerContext.Grid.EndUpdate(); |
113 | | - }).BeginGroup = true; |
114 | | - args.Items.AddCustomItem("Fix Column to the Right", () => { |
| 137 | + }); |
| 138 | + fixLeft.IconCssClass = "grid-context-menu-item-fix-column-left"; |
| 139 | + fixLeft.BeginGroup = true; |
| 140 | + |
| 141 | + var fixRight = args.Items.AddCustomItem("Fix Column to the Right", () => { |
115 | 142 | headerContext.Grid.BeginUpdate(); |
116 | 143 | headerContext.Column.FixedPosition = GridColumnFixedPosition.Right; |
117 | 144 | headerContext.Grid.EndUpdate(); |
118 | 145 | }); |
119 | | - args.Items.AddCustomItem("Unfix Column", () => { |
| 146 | + fixRight.IconCssClass = "grid-context-menu-item-fix-column-right"; |
| 147 | + |
| 148 | + var unfix = args.Items.AddCustomItem("Unfix Column", () => { |
120 | 149 | headerContext.Grid.BeginUpdate(); |
121 | 150 | headerContext.Column.FixedPosition = GridColumnFixedPosition.None; |
122 | 151 | headerContext.Grid.EndUpdate(); |
123 | 152 | }); |
| 153 | + unfix.IconCssClass = "grid-context-menu-item-unfix-column"; |
| 154 | + } |
124 | 155 |
|
125 | | - var isFooterVisible = headerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Always |
126 | | - || headerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Auto && headerContext.Grid.GetTotalSummaryItems().Count > 0; |
127 | | - string footerItemText = isFooterVisible ? "Hide Footer" : "Show Footer"; |
| 156 | + if (args.Context is GridFooterCommandContext footerContext) { |
| 157 | + var isFooterVisible = footerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Always |
| 158 | + || footerContext.Grid.FooterDisplayMode == GridFooterDisplayMode.Auto && footerContext.Grid.GetTotalSummaryItems().Count > 0; |
128 | 159 | var newFooterState = isFooterVisible ? GridFooterDisplayMode.Never : GridFooterDisplayMode.Always; |
129 | | - args.Items.AddCustomItem(footerItemText, () => { |
130 | | - headerContext.Grid.BeginUpdate(); |
131 | | - headerContext.Grid.FooterDisplayMode = newFooterState; |
132 | | - headerContext.Grid.EndUpdate(); |
| 160 | + var footer = args.Items.AddCustomItem("Footer", () => |
| 161 | + { |
| 162 | + footerContext.Grid.BeginUpdate(); |
| 163 | + footerContext.Grid.FooterDisplayMode = newFooterState; |
| 164 | + footerContext.Grid.EndUpdate(); |
133 | 165 | }); |
| 166 | + footer.IconCssClass = "grid-context-menu-item-footer"; |
| 167 | + footer.CssClass = isFooterVisible ? "menu-item-selected" : ""; |
134 | 168 | } |
135 | 169 | } |
136 | 170 |
|
|
0 commit comments