I was having some issues with a grid where I was getting an error saying that Description is not field that can be called on a null value, or something along those lines. TimeType is of type TimeTypeViewModel.
public class TimeTypeViewModel
{
public override string ID { get; set; }
public override string Description { get; set; }
}
columns.Bound(p => p.TimeType).Hidden(true).ClientTemplate("#= (typeof TimeType != 'undefined') ? TimeType.Description : ''#");
but the following code doesn't cause me any issues
but code doesn't cause me any issues
columns.Bound(p => p.TimeType).Hidden(true).ClientTemplate("#= typeof TimeType == 'undefined' || TimeType == null ? '' : TimeType.Description #");
Why is this? It seems that all the values (i.e. 'TimeType.Description') are being evaluated in the expression before actually checking to see if they should be evaluated based on the inline if condition. Is this a bug? Is this me not understanding how templates work? Is my code somehow bad, or only works on certain types?