silverlight datagrid 中的层次结构数据

发布于 2024-11-17 01:25:21 字数 487 浏览 9 评论 0原文

我正在尝试创建一个数据网格,其中第一列包含“+”号,下一列包含数据。当用户单击“+”号时,将从当前行获取数据,并且来自不同表的相应层次结构数据将显示在当前行下方的新网格中。我尝试在线搜索但找不到任何示例。

请建议我如何检查这一点。

假设网格包含

  • col1 Col2.... Col50
  • col1 Col2.... Col50

当用户单击“+”号时。

它应该读取 col1, Col2, Col3,Col4

然后进行 db 调用并根据上述值获取数据。

生成的网格应该是

  • col1 col2.... Col50 NestedCol1 NestedCol2... NestedCol20 NestedCol1 NestedCol2... NestedCol20 。 。 。 。 。
  • col1 col2... Col50

谢谢,纳文

I am trying to create a Datagrid where the first column contains '+' sign and next columns contain the data. When the user clicks the '+' sign the data is taken from the current row and the corresponding hierarchial data from different table is displayed in the new grid just below the current row. I tried searching online but could not find any example.

Please suggest me how to check this.

Lets say the grid contains

  • col1 Col2.... Col50
  • col1 Col2.... Col50

When the user clicks the '+' sign.

it should read col1, Col2, Col3,Col4

Then make a db call and get the data based on the above values.

the resulting grid should be

  • col1 col2.... Col50
    NestedCol1 NestedCol2... NestedCol20
    NestedCol1 NestedCol2... NestedCol20
    .
    .
    .
    .
    .
  • col1 col2... Col50

Thanks, Naveen

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

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

发布评论

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

评论(1

远昼 2024-11-24 01:25:21

看起来您必须在 DataGrid 中定义一个新的 RowDetailsTemplate。在资源中定义一个新的 DataTemplate,其中有一个包含两行的网格:

  • 第一行将是常规数据:col1,col2,...加上控制第二行的按钮(“+”按钮)
  • 第二行行中将有一个最适合您需求的新控件(ItemsControl、ListBox、DataGrid...)

“+”按钮将控制第二行的可见性以及相应行的数据加载。

我希望这会让你从正确的方向开始编辑

通过放入某种集合中,分层数据必须成为第一行中的数据的一部分,

public class Foo{
object Col1 {get;set;}
object Col2 {get;set;}

object Col50 {get;set;}
NestedFoo[] NestedData {get;set;}}

public class NestedFoo{
object NestedCol1 {get;set;}
object NestedCol2 {get;set;}

object NestedCol50 {get;set;}}

这样您就可以将第二行中的控件的 ItemsSource 设置为该集合。

Looks like you'll have to define a new RowDetailsTemplate in the DataGrid. In the Resources define a new DataTemplate that has a grid in it with two rows:

  • The first row will be the regular data :col1, col2,... plus the button that controls the second row (the '+' button)
  • The second row will have a new control in it that best suits your needs (ItemsControl, ListBox, DataGrid,...)

The '+" button would control the visibility of the second row and the loading of the data for the appropriate row.

I hope this will get you started in the right direction.

Edit:

The hierarchical data will have to be part of the data in the first row by placing into a collection of some sort.

public class Foo{
object Col1 {get;set;}
object Col2 {get;set;}

object Col50 {get;set;}
NestedFoo[] NestedData {get;set;}}

public class NestedFoo{
object NestedCol1 {get;set;}
object NestedCol2 {get;set;}

object NestedCol50 {get;set;}}

This way you can set the ItemsSource for the control in the second row to the collection.

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