MVCContrib 网格 MVC 3 Razor .RowStart
.RowStart 方法的示例遇到问题。
比较 2 种语法: http ://www.jeremyskinner.co.uk/2009/03/01/mvccontrib-grid-part-5-the-action-syntax/
在此
.RowStart(row => string.Format("<tr{0}>", row.IsAlternate ? "style=\"background-color:#CCDDCC\"" : ""))
row.IsAlternate
中抛出错误因为 row 不是 GridRow,它实际上是您的模型(以及行的数据项)。
第二种语法(ActionSyntax):
.RowStart((p,row) => {
if (row.IsAlternate) { %>
<tr style="background-color:#CCDDCC">
<% } else { %>
<tr>
<% }
}).Render(); %>
似乎没有转换为 Razor
.RowStart((x, row) => string.Format("<tr class='{0}'>", row.IsAlternate ? "grid-row" : "grid-row-alt"))
Passes,但不会发出任何行更改。
有人有这个工作吗?
Having trouble with the examples for the .RowStart method.
Comparing the 2 syntaxes: http://www.jeremyskinner.co.uk/2009/03/01/mvccontrib-grid-part-5-the-action-syntax/
In this
.RowStart(row => string.Format("<tr{0}>", row.IsAlternate ? "style=\"background-color:#CCDDCC\"" : ""))
row.IsAlternate
throws an error as row isnt the GridRow, its actually your model (well the row's data item).
The second syntax (ActionSyntax) :
.RowStart((p,row) => {
if (row.IsAlternate) { %>
<tr style="background-color:#CCDDCC">
<% } else { %>
<tr>
<% }
}).Render(); %>
doesnt seem to translate to Razor
.RowStart((x, row) => string.Format("<tr class='{0}'>", row.IsAlternate ? "grid-row" : "grid-row-alt"))
Passes ok, but doesn't emit any row changes.
Any had this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚注意到 Html.Grid 为您添加了一些约定内容...
以下
鉴于class =“grid”的表中的 结果,
偶数行具有 class =“gridrow”,
和类=“gridrow_alternate”的奇数行
I've just noticed some convention stuff that Html.Grid is putting in for you...
Given the Following
results in a table with class = "grid",
even rows with a class = "gridrow",
and odd rows with a class = "gridrow_alternate"
不确定这是否有帮助,但我最近一直在做的一件事是使用:
这允许我对属性的 css 值做很多事情。然后为了支持“斑马条纹”,我使用纯CSS(浏览器兼容性可能是一个问题,但它很优雅,只是不会在旧浏览器上呈现)看起来像
给你对表格的很好的控制。有关选择器的更多信息 Sitepoint 子选择器
否则,您可以尝试 针对 mvccontib 的 Google 群组 Jeremy 通常很敏锐,会提供帮助。
希望这有帮助。
Not sure if this will help but one thing I've been doing lately is using:
This allows me to do a lot with css values for the attributes. then for supporting "Zebra striping" I use pure css (browser compatibility could be an issue here, but it's graceful just doesn't render on old browsers) looks something like
Gives u great control over the table. More info on the selectors Sitepoint child selectors
Other wise you could try the google groups for mvccontib Jeremy is usually sharp of the mark to help out.
Hope this helped.