AdvantageGrid Class
Assembly: AdvantageCMS.Web.UI (in AdvantageCMS.Web.UI.dll)
Syntax
[ToolboxDataAttribute] [ToolboxBitmapAttribute] [DefaultPropertyAttribute] [DefaultEventAttribute] [DescriptionAttribute] public class AdvantageGrid : RadGrid, IAdvantageControl
Remarks
Data-object conventions. To unlock the full feature set the row's data object should expose:
- bool IsActive — required when ShowActiveButton is true. The active/inactive icon is chosen automatically per row; the toggle column auto-hides if the property is missing.
- bool IsFeatured — required when ShowFeatureButton is true. Same auto-hide behaviour.
- int SortOrder — set this from the OnReordered handler to persist drag-drop ordering.
Markup configuration. Declare visible columns inline with the Columns collection of GridColumnDefinition. Common attributes:
- DataKeyNames — comma-delimited primary-key field names; defaults to Id. Composite keys are supported.
- ShowAddFunction, ShowEditFunction, ShowDeleteFunction, ShowActiveButton, ShowFeatureButton — toggle the corresponding toolbar button or row column. All default to true.
- DisableSorting — when true, turns off drag-drop reordering and row selection.
Wiring events. Subscribe in the host's OnInit; only the events you handle will surface their column/button. OnLoadObject fires for both Add (toolbar) and Edit (row pencil) — distinguish via CommandType.
Resolving the clicked row. Event args carry an DataKeyValues list keyed by DataKeyNames. Use [GetRecordFromList{T}] to look up the record in your source list. After mutating state, call Rebind()()()() to refresh.
Selection state across postbacks.DataKeyItems holds the currently-selected row's keys (XML-serialised into ViewState), useful when an external edit form needs to know which row is being saved.
Examples
<%@ Register TagPrefix="advantage" Namespace="AdvantageCMS.Web.UI.Admin"
Assembly="AdvantageCMS.Web.UI" %>
<advantage:AdvantageGrid runat="server" ID="grdItems"
DataKeyNames="Id"
ShowActiveButton="true"
ShowFeatureButton="true"
OnNeedDataSource="grdItems_NeedDataSource">
<Columns>
<advantage:GridColumnDefinition HeaderText="Name" DataField="Name" Width="200" />
<advantage:GridColumnDefinition HeaderText="Type" DataField="TypeLabel" />
</Columns>
</advantage:AdvantageGrid>protected override void OnInit(EventArgs e) { grdItems.OnLoadObject += grdItems_LoadObject; // Add or Edit grdItems.OnDeleteObject += grdItems_DeleteObject; grdItems.OnToggleActive += grdItems_ToggleActive; // requires IsActive on item grdItems.OnToggleFeature += grdItems_ToggleFeature; // requires IsFeatured on item grdItems.OnReordered += grdItems_Reordered; // drag-drop committed base.OnInit(e); } protected void grdItems_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { grdItems.DataSource = MyItems; } private void grdItems_LoadObject(object sender, AdvantageGrid.AdvantageGridArgs args) { ClearForm(); if (args.CommandType == AdvantageGrid.GridCommandType.Add) return; // blank form for Add var item = AdvantageGrid.GetRecordFromList(MyItems, args.Item.DataKeyValues); // populate edit form from `item`... } private void grdItems_DeleteObject(object sender, AdvantageGrid.AdvantageGridArgs args) { var item = AdvantageGrid.GetRecordFromList(MyItems, args.Item.DataKeyValues); MyItems.Remove(item); Save(); grdItems.Rebind(); } private void grdItems_ToggleActive(object sender, AdvantageGrid.AdvantageGridToggleArgs args) { var item = AdvantageGrid.GetRecordFromList(MyItems, args.Item.DataKeyValues); item.IsActive = args.Toggle; // true = activate, false = deactivate Save(); } private void grdItems_ToggleFeature(object sender, AdvantageGrid.AdvantageGridToggleArgs args) { var item = AdvantageGrid.GetRecordFromList(MyItems, args.Item.DataKeyValues); item.IsFeatured = args.Toggle; Save(); } private void grdItems_Reordered(object sender, AdvantageGrid.AdvantageGridSortArgs args) { for (int i = 0; i < args.Items.Count; i++) { var item = AdvantageGrid.GetRecordFromList(MyItems, args.Items[i].DataKeyValues); item.SortOrder = i; } Save(); }
Inheritance Hierarchy
Control
WebControl
BaseDataBoundControl
DataBoundControl
CompositeDataBoundControl
RadCompositeDataBoundControl
GridBaseDataList
RadGrid
AdvantageCMS.Web.UI.Admin..::..AdvantageGrid

