asp.net mvc - Syntax complicated column in webgrid -


the column want accomplish has 3 possible outcomes.

  • the paiddate not empty --> show paiddate

  • the paiddate empty , duedate < --> shows: paiddate / "with reference" / reference + add class "green"

  • the paiddate empty , duedate > --> shows: paiddate / "with reference" / reference + add class "red"

the code i'm using doesn't recognize 'item' , have syntax errors aswell. how should build these if structures inside razor page using webgrid

codesample

grid.column("", "to 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);                                      }), 

this should work 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 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) )                                   )) }                         } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -