Aspxgridview the prerequisites for implementing data grouping:
Aspxgridviewbehaviorsettings.allowgroup=true must be set
First, data grouping from the server side
1. Using the GroupBy method for data grouping
Syntax 1:int GroupBy (gridviewcolumn column);
Syntax 2:int GroupBy (gridviewcolumn column, int value);
Where the parameter value represents the hierarchy of the grouping, 1 means that the grouping of the field is canceled.
Calling the GroupBy method does not automatically clear the previous grouping rule, and you can call the Clearsort method or ungroup method cleanup.
The following example shows grouping with one field:
this. Aspxgridview1.clearsort (); // Empty Group string This this. Aspxgridview1.columns[columnname]; this. Aspxgridview1.groupby (COL); // Grouping
The following example shows grouping with multiple fields:
this . Aspxgridview1.clearsort (); // empty grouping this . Aspxgridview1.groupby (this . aspxgridview1.columns["Event"]); // grouping this . Aspxgridview1.groupby (this . aspxgridview1.columns["Type"]); // grouping
2. Expand and collapse Grouping
(1) Use ExpandAll to expand all groupings.
Syntax: Void expandall ();
(2) Use Expandrow to expand the specified grouping row.
Syntax 1:void expandrow (int visibleindex);
Syntax 2:void expandrow (int visibleindex, bool recursive); The
parameter recursive sets whether recursive expansion groupings are enabled.
(3) collapses all groupings using CollapseAll.
Syntax: Void collapseall ();
(4) collapses the specified grouping rows using Collapserow.
Syntax 1:void collapserow (int visibleindex);
Syntax 2:void collapserow (int visibleindex, bool recursive); The
parameter recursive sets whether recursive collapse grouping is enabled.
3. Determine whether grouped rows expand
Use the Isrowexpanded method.
Syntax: bool isrowexpanded (INT VISIBLEINDEX);
4. Settings for data grouping
(1) Setting.groupformat the data format (readable and writable) used to set the grouped rows. The
Default is: {0}:{1}{2}. where {0} represents the label of the grouping field (the Caption property), {1} represents the grouping field value, and {2} represents the summary text. Brackets are automatically displayed in the middle of {1} and {2}.
The summary text is displayed only if the rollup is defined in the <GroupSummary > tab.
Example:
<groupsummary ><dxwgv:aspxsummaryitem fieldname="occdatetime" summarytype= " Count " /> </groupsummary >
(2) Setting.showgroupedcolumns is used to set whether the grouped fields are displayed. The default is true.
(3) Setting.showgroupedbuttons is used to set whether the Group expand button (+) is displayed. The default is true.
(4) Setting.showgroupfooter is used to set the block footer display mode (Gridviewgroupfootermode enum type). The default is hidden. Desirable values: Hidden, Visiblealways, visibleifexpanded.
hidden--not displayed
visiblealways--always shows
visibleifexpanded--only displayed when expanded
(5) packet data interval. The GroupInterval property.
Example:
<settings groupinterval= "Dateyear"/>
GroupInterval can be assigned the following values: Alphabetical, Date, Datemonth, DateRange, Dateyear, Default, DisplayText, value.
5. Sort by grouping values example:
This . ASPxGridView1.GroupSummarySortInfo.Clear (); this. ASPxGridView1.GroupSummarySortInfo.AddRange (new aspxgroupsummarysortinfo ("occdatetime "this. aspxgridview1.groupsummary["occdatetime"], columnsortorder.ascending));
Ii. implementing data grouping from the client
1. Using the GroupBy method for data grouping
Syntax 1:void GroupBy (int columnindex);
Syntax 2:void GroupBy (aspxclientgridviewcolumn column);
Syntax 3:void GroupBy (string columnfieldnameorid);
Syntax 4:void GroupBy (string columnfieldnameorid, int groupindex);
Syntax 5:void GroupBy (int columnindex, int groupindex);
Syntax 6:void GroupBy (aspxclientgridviewcolumn column, int groupindex);
Syntax 7:void GroupBy (int columnindex, int groupindex,string sortOrder);
Syntax 8:void GroupBy (aspxclientgridviewcolumn column, int groupindex, string sortOrder);
Syntax 9:void GroupBy (string columnfieldnameorid, int groupindex, string sortOrder);
2. Expansion and folding of groupings
(1) Use ExpandAll to expand all groupings.
Syntax: void ExpandAll ();
Use Expandrow to expand the specified grouping rows.
Syntax 1:void expandrow (int visibleindex);
Syntax 2:void expandrow (int visibleindex, bool recursive);
Parameter recursive: Whether recursion is recursive.
(3) Use CollapseAll to collapse all groupings.
Syntax: void CollapseAll ();
(4) Use Collapserow to collapse the specified grouping rows.
Syntax 1:void collapserow (int visibleindex);
Syntax 2:void collapserow (int visibleindex, bool recursive);
3. Determine whether the grouped rows are expanded
Use the Isgrouprowexpanded method.
Syntax: bool isgrouprowexpanded (int visibleindex);
4. Decide whether to group rows or rows of data
(1) Deciding whether to group rows
function Isgrouprow (visibleindex:int): bool;
(2) Determine if data rows
function Isdatarow (visibleindex:int): bool;
Third, the user drag the field to the grouping band to implement grouping
First you need to show the grouping bands:
Sets whether to show group band <settings showgrouppanel= "True"/>
Use the mouse to drag fields to the grouping band for instant grouping. Drag the grouping field back to the header to ungroup.
Source:. NET Learning Network
Description: All sources are . NET Learning Network articles are original, if reproduced, please mark this page address in the reprint, thank you!
11. Aspxgridview grouping from client and server side