在MVC3的WebGrid列应用特定的宽度 [英] Apply specific width in column of WebGrid in MVC3
本文介绍了在MVC3的WebGrid列应用特定的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.helpers.webgrid%28v=VS.99%29.aspx\">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文件:
.name {
width: 50px;
}
.address {
width: 300px;
}
这篇关于在MVC3的WebGrid列应用特定的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文