在 WPF 中对分类数据进行分组

发布于 2024-08-29 06:10:26 字数 1950 浏览 5 评论 0原文

这就是我正在尝试做的事情。

动态类别:

  1. 列可以是 0 个或多个。
  2. 必须包含 1 个或多个类型列
  3. 仅当任何行包含与其关联的类型列数据时才会显示。

数据行:

  1. 异步添加
  2. 将按Common 进行分组 类别列。
  3. 如果是,将添加动态类别 尚不存在。
  4. 如果有的话将添加一个类型列 尚未在其适当范围内存在 动态类别。

平台信息:

  • WPF
  • .Net 3.5 sp1
  • C#
  • MVVM

我有一些部分功能原型,但每个原型都有其自己的主要问题。你们中的任何人都可以给我一些指导吗?

想象一下这个漂亮的风格。 :-)

    --------------------------------------------------------------------------
    |[  Common Category  ]|[ Dynamic Category  0 ]|[   Dynamic Category N   ]|
    --------------------------------------------------------------------------
    |[Header 1]|[Header 2]|[  Type 0  ]|[ Type N ]|[  Type 0   ]|[  Type N  ]|
    --------------------------------------------------------------------------
    |[Data 2 Group]                                                          |
    --------------------------------------------------------------------------
    |  Data A  | Data 2  ||    Null    |  Data 1  ||   Data 0   |  Data 1   ||
    |  Data B  | Data 2  ||   Data 0   |   Null   ||   Data 0   |  Data 1   ||
    --------------------------------------------------------------------------
    |[Data 1 Group]                                                          |
    --------------------------------------------------------------------------
    |  Data C  | Data 1  ||    Null    |  Data 1  ||   Data 0   |  Data 1   ||
    |  Data D  | Data 1  ||    Null    |   Null   ||   Data 0   |   Null    ||
    --------------------------------------------------------------------------

编辑:排序和分页不是必需的。

我研究了嵌套的 ListViews 和 DataGrids,动态构建网格。动态构建网格并利用 SharedSizeGroup 属性似乎是最有前途的策略,但我担心性能。

更好的方法是将其视为动态报告吗?如果是这样,我应该注意什么?

感谢您的帮助。

Here is what I am trying to do.

Dynamic Category:

  1. Columns can be 0 or more.
  2. Must contain 1 or more Type Columns.
  3. Will only be displayed if any row contains Type Column data associated with it.

Data Rows:

  1. Will be added Asynchronously.
  2. Will be grouped by a Common
    Category
    column.
  3. Will add a Dynamic Category if it
    does not yet exist.
  4. Will add a Type Column if it does
    not yet exist within its appropriate
    Dynamic Category.

Platform Info:

  • WPF
  • .Net 3.5 sp1
  • C#
  • MVVM

I have a few partially functional prototypes, but each has it's own major set of problems. Can any of you give me some guidance on this?

Envision this nicely styled. :-)

    --------------------------------------------------------------------------
    |[  Common Category  ]|[ Dynamic Category  0 ]|[   Dynamic Category N   ]|
    --------------------------------------------------------------------------
    |[Header 1]|[Header 2]|[  Type 0  ]|[ Type N ]|[  Type 0   ]|[  Type N  ]|
    --------------------------------------------------------------------------
    |[Data 2 Group]                                                          |
    --------------------------------------------------------------------------
    |  Data A  | Data 2  ||    Null    |  Data 1  ||   Data 0   |  Data 1   ||
    |  Data B  | Data 2  ||   Data 0   |   Null   ||   Data 0   |  Data 1   ||
    --------------------------------------------------------------------------
    |[Data 1 Group]                                                          |
    --------------------------------------------------------------------------
    |  Data C  | Data 1  ||    Null    |  Data 1  ||   Data 0   |  Data 1   ||
    |  Data D  | Data 1  ||    Null    |   Null   ||   Data 0   |   Null    ||
    --------------------------------------------------------------------------

Edit: Sorting and Paging is not necessary.

I have looked at nested ListViews and DataGrids, dynamically building a Grid. Dynamically building a Grid and leveraging the SharedSizeGroup property seems the most promising strategy, but I am concerned about performance.

Would a better approach be to consider this a dynamic report? If so, what should I be looking at?

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人哭 2024-09-05 06:10:26

在我看来,你需要一个枢轴网格控件。

Infragistics 和 DevExpress

编辑: 但是,如果您手动执行此操作,我会得到类似的内容(从我的头顶开始)

Class Data
   Public Categories() as List
   Public Types() as List
   Public table as list( of row )
End Class

Class Row
   Public Category as string
   Public Type as string
   Public Group as string
   Public Header1 as string
   Public Header2 as string
   Public cell as string
End Class

然后我会编写一个如下函数:(伪代码)

function AddData( Category, Type, Group, theData )
    1. Search if the Category exist in array of categories, else add it
    2. Search if the Type exist in array of Types, else add it 
    3. add the rec
end function 

function DisplayData( )
   //show headers
   For each category in data.categories
      For each Type in data.categories
         AddColumn( Category, Type )
      next
   next
   //get the groups
   for each group in (from g in data.table select g.group).distinct
      for each category in data.categories
         for each type in data.types
            cell = (from r in data.table where r.category = category and r.type = type and r.group = group)
            if cell is nothing then
               addcell("null")
            else
               addcell(cell)
            end if
         next
      next
   next

我想我留下了可能具有共同类别的几行,但是您会明白的。
它的性能不是最好的,但很容易遵循。

In my opinion you need a pivot grid control.

There are good ones at Infragistics and DevExpress

Edit: but, if you do it manually, I would have something like this (from the top of my head)

Class Data
   Public Categories() as List
   Public Types() as List
   Public table as list( of row )
End Class

Class Row
   Public Category as string
   Public Type as string
   Public Group as string
   Public Header1 as string
   Public Header2 as string
   Public cell as string
End Class

Then I would code a function like: (pseudo-code)

function AddData( Category, Type, Group, theData )
    1. Search if the Category exist in array of categories, else add it
    2. Search if the Type exist in array of Types, else add it 
    3. add the rec
end function 

function DisplayData( )
   //show headers
   For each category in data.categories
      For each Type in data.categories
         AddColumn( Category, Type )
      next
   next
   //get the groups
   for each group in (from g in data.table select g.group).distinct
      for each category in data.categories
         for each type in data.types
            cell = (from r in data.table where r.category = category and r.type = type and r.group = group)
            if cell is nothing then
               addcell("null")
            else
               addcell(cell)
            end if
         next
      next
   next

I think I left behind the several rows that may have the common category, but you will get the idea.
It's not the best in performance, but it is easy to follow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文