0

我想要完成的专栏有 3 种可能的结果。

  • paidDate 不为空 --> 只显示paiddate

  • paidDate 为空,dueDate < NOW --> 显示:paidDate / "with reference" / reference + 添加一个类 "green"

  • paidDate 为空,dueDate > NOW --> 显示:paidDate / "with reference" / reference + 添加一个类 "red"

我现在使用的代码无法识别“项目”,而且我可能也有一些语法错误。如果使用 WebGrid 在剃刀页面内构建这些结构,我应该如何构建这些

代码示例

grid.Column("", "To be paid before", 
                    (item) =>   if(item.paidDate != null)
                                {
                                    string(item.paidDate);
                                }
                                else{
                                    if(item.dueDate < @DateTime.Now)
                                    {
                                        /*CLASS RED*/
                                        String.Format("{0}\br Met referentie: \br {1}", item.dueDate, item.reference);
                                    }
                                    else
                                    {
                                        /*CLASS GREEN*/
                                        String.Format("{0}\br Met referentie: \br {1}", item.dueDate, item.reference); 
                                    }),
4

1 回答 1

0

This should work for you

var grid = new WebGrid(source: Model.Modelname, rowsPerPage: 10, canSort: false);

                            @grid.GetHtml(
                                           tableStyle: "GridActionStyle",
                                      htmlAttributes: new { id = "grdid" },
                                      headerStyle: "headerStyle",
                                      alternatingRowStyle: "alt",
                                    columns: grid.Columns(
                                    grid.Column(header: "To be paid before", format: (item) => paidDate != null ?  string(item.paidDate) :  String.Format("{0}\br Met referentie: \br {1}", item.dueDate, item.reference) : String.Format("{0}\br Met referentie: \br {1}", item.dueDate, item.reference) )
                                  )) }
                        }
于 2013-07-26T12:01:56.177 回答