与MVCContrib排序 [英] Sorting with MVCContrib

查看:111
本文介绍了与MVCContrib排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何使用复杂的对象时,排序MVCContrib电网。

Does anyone know how to sort the MVCContrib grid when using a complex object.

我的网格显示人的名单,我想排序的国家属性。问题是,国家是一个属性的地址类,这是人的属性。

My grid is displaying a list of Person and I'm trying to sort on the Country property. The problem is that Country is a property an Address class which is a property of Person.

Person.Address.Country

Person.Address.Country

    <%Html.Grid(Model).Columns(column =>
   {
       column.For(x => x.Id);
       column.For(x => x.FirstName);
       column.For(x => x.LastName).Sortable(false);
       column.For(x => x.Address.Country).Sortable(false);
       column.For(x => x.Age).Sortable(true);
   }).Render(); %>

例外:结果
属性国家没有为类型定义{命名空间} .Person的结果
VAR sourceProp =前pression.Property(sourceParam,this.SortBy);
\\ MVCContrib \\ UI \\网格\\可排序\\ ComparableSortList.cs行:41

Exception:
Property 'Country' is not defined for type '{Namespace}.Person'
var sourceProp = Expression.Property(sourceParam, this.SortBy); \MVCContrib\UI\Grid\Sortable\ComparableSortList.cs Line: 41

任何建议将是有益的。

Any suggestions would be helpful.

感谢您,

MG1

推荐答案

一个解决方法是暴露国家作为人<属性/ code>并使用:

A workaround would be to expose Country as a property on Person and use that:

public string Country { get { return Address.Country; } }

这篇关于与MVCContrib排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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