MVC 3的WebGrid列排序alphabatically,不按表结构 [英] MVC 3 WebGrid Column Sort alphabatically, not according to table structure

查看:125
本文介绍了MVC 3的WebGrid列排序alphabatically,不按表结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经分配的数据给的WebGrid,但按字母顺序排序的列。它是根据表结构没有显示的列像ASP DataGrid中。

例如,如果表有作为列

  ID标题artid的数据类型

然后网格显示排序的列后,它们:

  artid的数据类型ID称号


解决方案

如果你还在寻找这个答案,我发现在这里:

 < H2>指数< / H>
@ {
    VAR电网=新的WebGrid(来源:型号,
        defaultSort:ID,
        rowsPerPage:10);
}
&所述p为H.;
    @ Html.ActionLink(新建,创建)
&所述; / P>
< D​​IV ID =网格>
    @ grid.GetHtml(列:grid.Columns(
                    grid.Column(ID,ID),
                    grid.Column(称号,标题),
                    grid.Column(艺术家,艺术家)));
< / DIV>

希望这有助于!

I have assigned data to the webgrid but it sorting the columns alphabetically. it is not showing columns as like in asp datagrid according to table structure.

for example if table have columns as"

id  title  artid   

then grid showing them after sorting the columns as:

artid  id title

解决方案

If you are still looking for this answer I have found it here:

 <h2>Index</h2>
@{
    var grid = new WebGrid(source: Model,
        defaultSort: "id",
        rowsPerPage:10);    
}
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<div id="grid">
    @grid.GetHtml(columns: grid.Columns(
                    grid.Column("id", "ID"),
                    grid.Column("title", "Title"),
                    grid.Column("artist", "Artist")));
</div>

Hope this helps!

这篇关于MVC 3的WebGrid列排序alphabatically,不按表结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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