How to: Configure Bands in a Grid List Editor (WinForms and ASP.NET) 如何:在网格列表编辑器中配置波段(WinForms 和ASP.NET)

This topic describes how to group grid columns using bands in both WinForms and ASP.NET XAF applications. Mobile applications do not support bands, so the approach described in this topic cannot be implemented in the Mobile platform.

本主题介绍如何使用 WinForms 和ASP.NET XAF 应用程序中的波段对网格列进行分组。移动应用程序不支持频段,因此本主题中描述的方法无法在移动平台中实现。

Note 注意
If you prefer to watch a video rather than walk through these step-by-step instructions, visit the corresponding tutorial on the DevExpress YouTube Channel: XAF: Bands in Grid List Editors . You can also see a demonstration of bands in the List Editors | Grid | Banded List View section of the Feature Center demo. The Feature Center demo is installed in %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\FeatureCenter by default. The ASP.NET version of this demo is available online at http://demos.devexpress.com/XAF/FeatureCenter/
如果您更喜欢观看视频,而不是演练这些分步说明,请访问 DevExpress YouTube 频道上的相应教程:XAF:网格列表编辑器中的波段。您还可以在列表编辑器中看到波段的演示 |网格 |功能中心演示的带状列表视图部分。功能中心演示安装在%PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\FeatureCenter by default. The ASP.NET version of this demo is available online at http://demos.devexpress.com/XAF/FeatureCenter

 

In this example, the Simple Project Manager demo application installed to the %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\SimpleProjectManager is used. However, you can follow the steps below in any XAF application that provides a List View with several columns, but obviously the captions will differ.

在此示例中,使用安装在 %PUBLIC%_文档_DevExpress 演示 19.2_组件_eXpressApp 框架_简单项目经理管理器的简单项目经理演示应用程序。但是,您可以在任何 XAF 应用程序中执行以下步骤,该应用程序提供包含多列的列表视图,但标题显然会有所不同。

 

1. Run the Model Editor for the platform-agnostic module. In the node tree to the left, find the ListView node that you are going to customize (e.g., the ProjectTask_ListView node). Focus the BandsLayout child node. In the property grid to the right, set the IModelBandsLayout.Enable property to true.

   运行与平台无关的模块的模型编辑器。在左侧的节点树中,查找要自定义的 ListView 节点(例如,ProjectTask_ListView节点)。聚焦波段Layout子节点。在右侧的属性网格中,将 IModelBandsLayout.enable 属性设置为 true。

Bands_BandsLayout.Enable

 

2. After changing the Enabled value, you will notice that now it is possible to expand the child nodes of the BandsLayout node. By default, no bands are added, and this node contains columns only. To add a band, right-click BandsLayout and choose Add... | Band.

   更改启用值后,您会注意到现在可以展开波段Layout节点的子节点。默认情况下,不添加波段,并且此节点仅包含列。要添加波段,请右键单击"波段"并选择"添加..." |乐队。

Bands_AddBand

 

3. Focus the newly added node and specify a meaningful Id for it (e.g., TaskDetails).

    聚焦新添加的节点并为其指定有意义的 ID(例如,任务详细信息)。

Bands_SetIdToTaskDetails

Note 注意
The IModelBand.Caption of a band is filled automatically based on the Id value. However, you can change the caption when required.
根据 Id 值自动填充波段的 IModelBand.标题。但是,您可以在需要时更改标题。

 

4. Select columns to be added to the TaskDetails band (hold the CTRL key and click the corresponding nodes). Then, drag the selected columns to the TaskDetails band node.

    选择要添加到任务详细信息波段的列(按住 CTRL 键并单击相应的节点)。然后,将所选列拖动到"任务详细信息"波段节点。

Bands_DragToTaskDetails

 

5. Analogously, add another band (e.g., Schedule) and move the remaining columns into it. The resulting bands layout is illustrated below.

    类似地,添加另一个波段(例如,计划),并将剩余的列移到其中。生成的波段布局如下图所示。

Bands_DragToScheduleResult

Tip 提示
You can add a band inside an existing band to create a complex bands hierarchy.
您可以在现有波段内添加波段以创建复杂的波段层次结构。

 

6. Run the WinForms application to see the result. According to the bands layout illustrated in the previous step, the ProjectTask List View has two bands - Schedule and TaskDetails. The Schedule band enclosures the Start Date and End Date columns.    The Subject, Status and Assigned To columns are grouped into the TaskDetails band.

  运行 WinForms 应用程序以查看结果。根据上一步中所示的波段布局,ProjectTask 列表视图有两个波段 - 计划和任务详细信息。计划带存储模块为开始日期和结束日期列。"主题、状态"和"已分配到"列将分组到"任务详细信息"波段。

Bands_Win

 

7. Run the ASP.NET application to ensure that the bands layout is exactly the same.

    运行ASP.NET应用程序,以确保波段布局完全相同。

Bands_Web

 

8. Now let us try the extra configuration options available for WinForms only. Stop debugging and run the Model editor for the WinForms module project. In the node tree to the left, find the BandsLayout node that you configured in the previous steps.

    Focus a column within a band (e.g., Subject). Change the IModelBandedColumnWin.RowIndex value to 1.

   现在,让我们尝试一下仅适用于 WinForms 的额外配置选项。停止调试并运行 WinForms 模块项目的模型编辑器。在左侧的节点树中,查找在前面的步骤中配置的波段Layout 节点。将列聚焦在波段内(例如"主题")。将 IModel 波段Win.RowIndex 值更改为 1。

Bands_RowIndex

Tip 提示
In WinForms, you can specify what customization capabilities of bands are allowed to end users and hide band/column headers using the IModelBandsLayoutWin properties.
在 WinForms 中,您可以指定允许最终用户使用波段/列头的自定义功能,并使用 IModelBandsLayoutWin 属性隐藏波段/列头。

 

9. Run the WinForms application to see the result. The Subject column is now displayed below the Status and Assigned To columns that have zero RowIndex.

    运行 WinForms 应用程序以查看结果。"主题"列现在显示在"状态"和"分配给具有零行索引"的列下方。

Bands_WinAdv

Important

When configuring bands, keep in mind the differences in behavior between WinForms and ASP.NET grid controls:

  • Columns that are not added to any band are visible in ASP.NET applications only. The WinForms grid control does not display such columns.
  • The IModelBandedColumnWin.RowIndex option is available for WinForms only. You cannot arrange column headers across rows in ASP.NET applications.
  • Options that restrict band configuration by users (see IModelBandsLayoutWin) are available in WinForms only.

That is why we recommend the following:

  • Setup bands separately for WinForms and ASP.NET. Configuring bands in a platform-agnostic module is suitable for very simple band layouts only.
  • Avoid merging platform-specific band configuration in a common module.

重要

配置波段时,请记住 WinForms 和ASP.NET网格控件之间的行为差异:

  • 未添加到任何波段的列仅在ASP.NET应用程序中可见。WinForms 网格控件不显示此类列。
  • IModelBandedColumnWin.RowIndex 选项仅适用于 WinForms。不能跨ASP.NET应用程序中的行排列列标题。
  • 限制用户波段配置的选项(请参阅 IModelBandsLayoutWin)仅在 WinForms 中可用。

因此,我们建议:

  • 为 WinForms 和ASP.NET单独设置波段。在与平台无关的模块中配置频段仅适用于非常简单的波段布局。
  • 避免在通用模块中合并特定于平台的频段配置。
posted @ 2020-01-07 11:41  code first life  阅读(211)  评论(0编辑  收藏  举报