HTML页面

            <dx:ASPxGridView ID="grvList" Width="100%" runat="server" AutoGenerateColumns="False" ClientInstanceName="grvList" KeyFieldName="id1;id2" 
        OnDataBound="grvList_DataBound"> <%-- 列集合 --%>
<Columns>
<dx:GridViewDataTextColumn Caption="列1" FieldName="Column1" VisibleIndex="0" GroupIndex="0" FixedStyle="Left" ShowInCustomizationForm="True">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="列2" FieldName="Column2" VisibleIndex="1" GroupIndex="1" FixedStyle="Left" ShowInCustomizationForm="True">
</dx:GridViewDataTextColumn> <%-- 列分组1 --%>
<dx:GridViewBandColumn Caption="列分组1" Name="BandColumn2">
<Columns>
<dx:GridViewDataTextColumn FieldName="Column3" Caption="列分组1-列3" PropertiesTextEdit-DisplayFormatString="N" Width="90px" />
<dx:GridViewDataTextColumn FieldName="Column4" Caption="列分组1-列4" PropertiesTextEdit-DisplayFormatString="N" Width="90px" />
</Columns>
</dx:GridViewBandColumn> <%-- 列分组2 --%>
<dx:GridViewBandColumn Caption="列分组2" Name="BandColumn2">
<Columns>
<dx:GridViewDataTextColumn FieldName="Column5" Caption="列分组2-列5" PropertiesTextEdit-DisplayFormatString="N" Width="90px" />
<dx:GridViewDataTextColumn FieldName="Column6" Caption="列分组2-列6" PropertiesTextEdit-DisplayFormatString="P3" Width="90px" />
</Columns>
</dx:GridViewBandColumn>
</Columns> <%-- 分页设置 --%>
<SettingsPager PageSize="10" Mode="ShowPager">
<FirstPageButton Visible="True" />
<LastPageButton Visible="True" />
<PageSizeItemSettings Items="10, 15, 20, 50, 100" ShowAllItem="True" Visible="True" />
</SettingsPager> <%-- 外观设置 --%>
<Settings HorizontalScrollBarMode="Auto" ShowGroupPanel="true" VerticalScrollBarMode="Visible" VerticalScrollableHeight="300" ShowHeaderFilterButton="false" /> <%-- 行为设置 --%>
<SettingsBehavior AllowFocusedRow="true" EnableRowHotTrack="False" AllowGroup="true" ColumnResizeMode="Control" /> <%-- 样式设置 --%>
<Styles>
<Header HorizontalAlign="Center"></Header>
<Cell Wrap="False"></Cell>
<AlternatingRow Enabled="True"></AlternatingRow>
</Styles>
</dx:ASPxGridView>

代码页面

     protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridViewDataBind();
}
       //AspxGridView回调加载数据
if(grvList.IsCallback)
{
GridViewDataBind();
}
}      //数据绑定后展开数据分组第1层
protected void grvList_DataBound(object sender, EventArgs e)
{
var grid = sender as ASPxGridView;
for(int i=; i<grid.GroupCount; i++)
{
if (grid.GetRowLevel(i) == ) grid.ExpandRow(i);
}
}

PS:

GroupIndex="0" 默认的分组列索引,可同时设置多个;
FixedStyle="Left" 靠左锁定列,可同时设置多个;
05-25 18:28