【问题标题】:MVC WebGrid - Set Column WidthMVC WebGrid - 设置列宽
【发布时间】:2013-07-22 18:07:51
【问题描述】:

我正在尝试在 MVC WebGrid(最后一列)中设置列的宽度,但尽管在 grid.column 声明中应用了一个类(如下面的代码所示),但宽度并没有改变。

该类已成功应用于 html,但仅应用于节内的行,而不应用于节内的列标题单元格。起初我以为这是浏览器中的宽度没有改变的原因,但后来我将该类添加到浏览器的标题单元格中(使用开发工具),它仍然没有改变宽度。

  @grid.GetHtml(tableStyle: "webgrid",                              
    headerStyle: "webgrid-header",                           
    footerStyle: "webgrid-footer",                          
    alternatingRowStyle: "webgrid-alternating-row",                         
    selectedRowStyle: "webgrid-selected-row",                           
    rowStyle: "webgrid-row-style",
    columns: grid.Columns(                                                                       
      grid.Column("Source", header: "source"),                                                                      
      grid.Column("Note", header: "note"),                                                                      
      grid.Column("Created", header: "created", format: @<text>@item.Created.ToString("dd-MMM-yyyy HH:mm")</text>),                                                                     
      grid.Column("Data", header: "data", canSort: true, style: "dataColWidthStyle")                                                                       
    )
   )

你能帮忙吗?

【问题讨论】:

    标签: css asp.net-mvc styling webgrid


    【解决方案1】:

    您需要在 CSS 中设置列​​的宽度。

    当您使用表头时,不要忘记在&lt;thead&gt; 中设置&lt;th&gt; 标签的宽度,而不是&lt;tbody&gt;&lt;td&gt; 标签。

    【讨论】:

      猜你喜欢
      • 2016-01-17
      • 2013-02-13
      • 1970-01-01
      • 2014-08-31
      • 2012-02-17
      • 2012-02-24
      • 1970-01-01
      • 2013-06-25
      • 2013-01-07
      相关资源
      最近更新 更多