有没有办法在 WebGrid 中拥有两行标题?
我寻找一种方法来对标题进行自定义渲染,或者寻找一种仅渲染表格主体(没有表格标签)的方法,但我找不到任何东西。
我想创建一个看起来像这样的网络网格:
-------------------------------------------
|grouped cols |grouped cols|
-------------------------------------------
|col1 | col2 | col3 | col4 | col5 |col6 |
-------------------------------------------
-------------------------------------------
|d1 | d2 | d3 | d4 | d5 |d6 |
-------------------------------------------
|d1 | d2 | d3 | d4 | d5 |d6 |
-------------------------------------------
|d1 | d2 | d3 | d4 | d5 |d6 |
-------------------------------------------
请记住,我是 mvc3 的新手(所以我可能会错过明显的解决方案)。
最佳答案
服务器端解决方案:
@(new HtmlString(grid.GetHtml(Your grid definition).ToHtmlString()
.Replace("<thead>",""<thead><tr class='webgrid-header'><th scope='col' colspan='4'>cols 1 to 4</th><th scope='col' colspan='2'>cols 5 and 6</th></tr>")))
客户端(假设 View 中只有一个 webgrid,您可以使用一些 jquery):
@Scripts.Render("~/bundles/jquery")
<script>
$(function () {
var th = $("<tr class='webgrid-header'><th scope='col' colspan='4'>col 1 to 4</th><th scope='col' colspan='2'>col 5 and 6</th></tr>")
$("thead").prepend(th);
});
</script>
关于asp.net-mvc - mvc3 WebGrid 中的两行标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17398688/