在MVC3中的WebGrid列中应用特定宽度 [英] Apply specific width in column of WebGrid in MVC3

查看:26
本文介绍了在MVC3中的WebGrid列中应用特定宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过 WebGrid 以利用 MVC 应用程序中的内置排序和分页,它运行良好,只有一个我无法解决的问题,在这里寻找任何人的帮助

I Have used WebGrid to take benefit of inbuilt sorting and paging in MVC application and it's worked very well only one issue i could not fix and looking here for anyone's help

我的 webgrid 如下所示

My webgrid is look like as per below

@{
        var grid = new WebGrid(Model, canSort: true, canPage: true, rowsPerPage: 10);
        grid.Pager(WebGridPagerModes.NextPrevious);
        @grid.GetHtml(columns: grid.Columns(

        grid.Column("Name", "Name", canSort: true),
        grid.Column("Address", "Address", canSort: true),        
        //other columns
        ));
  }

如何根据我的要求固定每一列的宽度?(不同的列需要不同的宽度)

How can i fixed the width of every column as per my requirement? (need different width for different column)

推荐答案

您可以使用样式:

@grid.GetHtml(columns: grid.Columns(
    grid.Column("Name", "Name", canSort: true, style: "name"),
    grid.Column("Address", "Address", canSort: true, style: "address")
));

并在您的 CSS 文件中:

and in your CSS file:

.name {
    width: 50px;
}

.address {
    width: 300px;
}

这篇关于在MVC3中的WebGrid列中应用特定宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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