Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4285

Blazor : calculate a value or leave as default

$
0
0

if I want to supply a calculated value to a component such as a grid or any parameter really, and if there is no value then I want to leave the value as it was since it is being automatically calculated by that component, such as a default col width.

Basically I want to say parameter = calculated value or if not found leave as it was, i'm struggling with having to provide a value in the 'or' case that is affecting the original defaulted value...like this:

Width="@dict.GetValueOrDefault(colWidth, "")"

If I provide the "" as the default then it overrides what the component was doing on its own.

Alternatively:

Width = valueFound ? value : 0;

The zero is now overriding the original value, and I don't have access to 'Width' since it is a parameter of a grid component, not something I can access if that makes sense.

I want to do this:

Width = valueFound ? value : "LEAVE WHATEVER WIDTH WAS ORIGINALLY";

TYIA

Actual example

<DxGrid Data="@data"    @ref="Grid"><Columns>    @foreach (DataColumn col in data.Columns)    {<DxGridDataColumn FieldName="@data.colName"                          Width="@valueFound ? value : **LEAVE WHATEVER WIDTH WAS ORIGINALLY**</DxGridDataColumn>                                     }</Columns>

Viewing all articles
Browse latest Browse all 4285

Trending Articles