如何使用 Telerik RadGrid 控件合并列
我知道我需要使用模板列,但我不清楚如何使用它。
我有一个返回集合的数据源,我可以将集合中的每个属性分配给一列。
但我该如何:
- 合并两列?例如
col.prop1 +' '+ col.prop2
? - 对属性执行一些方法,例如
col.prop1.ToString(overloaded)
一个简单的代码隐藏示例会有所帮助。我能找到的都是非常复杂的控件和示例。
谢谢。
I know I need to use Template Columns, but I am not clearly understanding how to use it.
I have a datasource which returns a collection, I can assign each property in the collection to a column.
But how do I:
- Merge two columns? such as
col.prop1 +' '+ col.prop2
? - Execute some methods on the properties such as
col.prop1.ToString(overloaded)
A simple codebehind example will help. All I can find are very complex controls and stuff for examples..
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还可以使用计算列
http://demos.telerik .com/aspnet-ajax/grid/examples/generalfeatures/calculatedcolumns/defaultcs.aspx
You can also use calculated columns
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/calculatedcolumns/defaultcs.aspx
假设您可以修改集合中使用的类,我将创建一个“显示”属性。
然后您可以将其分配给绑定列。我发现这更好,因为您不必担心软件不同区域的格式不同。基本上,它允许重复使用。
另一种方法是创建一个模板列并使用绑定表达式。您可以在 MSDN 或 Telerik 的帮助中找到有关数据绑定表达式的信息,但您需要执行如下操作:
编辑
下面是一个 URL,可让您查看一些网格模板内容: http:// /www.telerik.com/help/aspnet-ajax/grdcustomizewithgridtemplatecolumn.html
Assuming you can modify the class that is used in the collection, I would make a "display" property.
You can then assign that to a bound column. I find that this is better since you won't have to worry about having the formatting different in different areas of the software. Basically, it allows for reuse.
The other way to do it would be to indeed create a template column and using binding expressions. You can find out about data binding expressions either on MSDN or in Telerik's help, but you're going to want to do something like this:
EDIT
Here is a URL that will allow you to look at some Grid template stuff: http://www.telerik.com/help/aspnet-ajax/grdcustomizewithgridtemplatecolumn.html
我想到的唯一方法是对属性和代码隐藏方法使用绑定表达式,这些方法通过这些绑定表达式从属性方法返回结果。
The only way that comes to my mind is to to use binding expressions for the properties and code-behind methods that return the results from the property methods through those binding expressions.