PDA

View Full Version : Change column from True False to Yes No



Shahaf
Sep 19, 2015, 10:18 PM
Hi,
I have a column (in a gridPanel) with true false data
i want to change it to Yes No
How can i do it?

Thanks!!

code example:


Html.X().ColumnFor(Model, item => item.indoor)
//.BooleanColumn().TrueText("Yes").FalseText("No") ---> dosen't work
.ToBuilder<Column.Builder>()
.Flex(1)

Daniil
Sep 22, 2015, 9:38 AM
Hi @Shahaf,

There are two alternative approaches:

1. You should pass the BooleanColumn.Builder type into a generic .ToBuilder<>() call.

Html.X().ColumnFor(Model, item => item.indoor)
.ToBuilder<BooleanColumn.Builder>()
.TrueText("Yes")
.FalseText("No")

2. Using a BooleanColumn attribute for the property in the Model:

[BooleanColumn(TrueText = "Yes", FalseText = "No")]
public bool indoor
{
get;
set;
}

Shahaf
Sep 22, 2015, 11:47 AM
When i try to use one of your suggestions i get the following error:


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 49: <h1>Index</h1>
Line 50:
Line 51: @(Html.X().GridPanel()
Line 52: .Icon(Icon.Table)
Line 53: .Frame(true)

Daniil
Sep 22, 2015, 3:08 PM
With the approach #1 the Model's property should have a BooleanColumn attribute still.

[BooleanColumn]
public bool indoor
{
get;
set;
}

Shahaf
Sep 23, 2015, 6:46 PM
again, Thanks for your help!