c# - How to create a custom format to webgrid column helper? -


i need create custom format in webgrid helper. i'm trying way, not working.

    if (fieldtype == fieldtype.currency && format == null)         format = x => string.format(cultureinfo.currentculture, "$ {0}", x.reductionvalue);      this.columns.add(new gridcolumn()     {         columnname = columnname,         header = displayname,         format = format,         style = stylecolumn,         cansort = cansort     }); 

i need result be:

$ myvalue example: $ 1.000,00

how can this?

i had same doubt, when trying format column of webgrid.

i did this, think same want do:

public void addcurrencycolumn(expression<func<t, decimal?>> expression)         {             func<t, decimal?> compiledexpression = expression.compile();             this.columns.add(new webgridcolumn()             {                 columnname = "id",                 header = string.empty,                 format = (item) => string.format(system.globalization.cultureinfo.currentculture, "$ {0}", compiledexpression(item.value)),                 style = "currency-webgrid-column"             });         } 

as can see, compiled expression , then, used model property value.

if want more generic, replace type decimal?for generic type , verify before want do.

maybe have resolved problem, but, perhaps may else.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -