MVCCONTRIBグリッドモデル値に基づく条件付きセルフォーマット

StackOverflow https://stackoverflow.com/questions/4774341

  •  23-10-2019
  •  | 
  •  

質問

モデルのブール値に基づいてセル値を条件付けする必要があります。列col.for(item => item.detail)があります。 item.unfinishedの場合、CSSスタイルを適用する必要があります。どうすればよいですか?

役に立ちましたか?

解決

答えは、元の投稿への私のコメントにあります:

http://groups.google.com/group/mvccontrib-discuss/browse_thread/thread/f872d298cc9d53dc

column.For(x => x.Surname).Attributes(x => {
    if(x.Item.Surname == "foo") {
        return new Dictionary<string, object> { { "style", "color:red"} };
    }
    return new Dictionary<string, object>();
});

他のヒント

まだ解決策を探している場合:

「MVCCONTRIBグリッドの上記のプロパティもトリックを行います。

<%= Html.Grid(Model.Services).AutoGenerateColumns()
    .Columns(column => {
        column.For(a => Html.ActionLink("Editar", "Edit", new { id = a.Id }))
            .InsertAt(0).Encode(false)
            .CellCondition(x => 
                (x.CreatedBy==Membership.GetUser().UserName));
    })
    .Sort(Model.GridSortOptions)
    .Attributes(@class => "table-list")
    .Empty(Resources.NO_DATA_TO_DISPLAY)
%>

"

ジェレミー・スキナーへのクレジットhttp://www.jeremyskinner.co.uk/2010/04/27/mvccontrib-grid-part-7-auto-generated-columns/comment-page-1/#comment-19059

そして、元々ここに投稿したjpassos:http://forums.asp.net/p/1559843/3850767.aspx

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top