如何绑定一个Telerik的格列一个子数据对象,它是一个列表? [英] How to bind a telerik grid column to a child data object that is a list?

查看:230
本文介绍了如何绑定一个Telerik的格列一个子数据对象,它是一个列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定多个子数据对象的列没有问题,在使用的 http://www.telerik.com/help/aspnet-ajax/grdbindingtosubobjects.html

I have a grid that binds a number of child data objects to columns with no issue, using the syntax defined at http://www.telerik.com/help/aspnet-ajax/grdbindingtosubobjects.html.

我想不出有什么,但是,是如何聚合一个子对象,它是一个列表或集合。举例来说,如果我有一个客户对象,我想要得到的客户的第一个街道地址,我会使用数据字段=Customer.Addresses [0] .Street上标准 GridBoundColumn
我怎样才能获得地址的计数?我已经试过各种GridCalculatedColumn数据域和Ex pressions的,都无济于事。我找了沿此线的东西:

What I can't figure out, however, is how to aggregate a child object that is a list or collection. For example, if I have a Customer object and I want to get the customer's first street address, I would use DataField="Customer.Addresses[0].Street" on a standard GridBoundColumn. How can I get the count of the addresses? I have tried all sorts of GridCalculatedColumn DataFields and Expressions, to no avail. I am looking for something along the lines of this:

这是行不通的,当然。事实上,如果我尝试做任何点缀数据领域的伯爵,我得到一个异常

That doesn't work, of course. In fact, if I try to do a Count on any dotted data field, I get an exception of

System.Data.SyntaxErrorException:合计参数语法错误:期待可能出现的'儿童'预选赛一列参数

例如,只是想用计数的前pression({0})设置为 Customer.FirstName <数据域/ code>(其中只有一个),会导致异常在运行时被抛出。做同样的事情与非点数据字段,诸如SendDate,不引起相同的异常。

For example, just trying to use an expression of Count({0}) with DataFields set to Customer.FirstName (of which there is only one), causes that exception to be thrown at runtime. Doing the same thing with a non-dotted data field, such as SendDate, does not cause the same exception.

推荐答案

好像你已经收到的答案,从<一个这个问题, href=\"http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-bind-a-column-to-a-child-data-object-that-is-a-list.aspx\"相对=nofollow> Telerik的论坛但人们对这个问题有可能绊倒在寻找一个答案。

Seems like you already received an answer to this question from the Telerik forums but for people that might stumble upon this question looking for an answer.

本质上radgrid控件不支持一种在其数据域集合,支持的绑定属性的类型可以发现的此处。因此,在这种聚合的角度,你既可以做到过这个集合计算它绑定到radgrid控件之前有一个聚合列定义,或者你可以考虑使用页脚很像的这个演示

Essentially the RadGrid does not support having Collections in its DataFields, and the supported bindable property types can be found here. So in terms of this aggregation you could either do a calculation across this collection before binding it to the RadGrid and have an aggregate column defined, or you could look into using footers much like in this demo.

这篇关于如何绑定一个Telerik的格列一个子数据对象,它是一个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆