Datagrid RowSelect not visually selected

Hi!

Trying out the DataGrid with RowSelect and got into a strange problem:

This one works fully, both OnValueClick gets called and row gets visually selected:

RowSelect="@OnValueClick" Data="@afValues" AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="10" TItem="CAfValue" ColumnWidth="150px" Style="width: 100%;"

This one, however manages to call the OnAttributeClick but does not visually render the row as selected:

RowSelect="@OnAttributeClick" Data="@attributes" AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="20" TItem="CAfAttribute" ColumnWidth="150px" Style="width: 100%;"

What can possibly affect this behavior?
Any suggestions?

BR
Ove

Can you post more info about afValues, attributes, item types and what's the code of RowSelect event handlers?

Sure! I'll start with this:

Working example:

<RadzenGrid RowSelect="@OnValueClick" Data="@afValues" AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="10" TItem="CAfValue" ColumnWidth="150px" Style="width: 100%;">
	<Columns>
		<RadzenGridColumn TItem="CAfValue" Property="HistDateTime" Title="Date" />
		<RadzenGridColumn TItem="CAfValue" Property="HistValueStr" Title="Value" />
	</Columns>
</RadzenGrid>

Model:

public class CAfValue : ICAfValue
{
    public string ElementId { get; set; }
    public string AttributeId { get; set; }
    public DateTime HistDateTime { get; set; }
    public double? HistValueNum { get; set; }
    public string HistValueStr { get; set; }
    public bool IsGood { get; set; }
}

Code is deliberately doing nothing:

protected async Task OnValueClick(CAfValue args)
{
} 

Non-working example: (OnAttributeClick gets run but row is not visually selected),

<RadzenGrid RowSelect="@OnAttributeClick" Data="@attributes" AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="20" TItem="CAfAttribute" ColumnWidth="150px" Style="width: 100%;">
	<Columns>
		<RadzenGridColumn TItem="CAfAttribute" Property="Name" Title="Name" />
		<RadzenGridColumn TItem="CAfAttribute" Property="CurrentValueNum" Title="Current value" />
		<RadzenGridColumn TItem="CAfAttribute" Property="DefaultUOM" Title="UOM" />
	</Columns>
</RadzenGrid>

Model:

public class CAfAttribute
{
    public string ElementId { get; set; }
    public string HistDateTime { get; set; }
    public string AttributeId { get; set; }
    public string LabId { get; set; }
    public bool GetHistData { get; set; }
    public string Name { get; set; }
    public string ElementPath { get; set; }
    public DateTime HistDateTime { get; set; }
    public string ImportUOM { get; set; }
    public string DefaultUOM { get; set; }
    public string Id { get; set; }
    public string AttributePath { get; set; }
    public string Description { get; set; }
    public string Type { get; set; }
    public bool HasChildren { get; set; }
    public string ElementName { get; set; }
    public bool IsDeleted { get; set; }
    public bool IsExcluded { get; set; }
    public bool IsHidden { get; set; }
    public bool IsManualDataEntry { get; set; }
    public string CurrentValueStr { get; set; }
    public double? CurrentValueNum { get; set; }
    public string HistValueStr { get; set; }
    public double? HistValueNum { get; set; }
}

Code is deliberately doing nothing, but gets called:

protected async Task OnAttributeClick(CAfAttribute args)
{
}

Any difference between both enumerables?

They look like this:

    // Attributes section
    protected IEnumerable<CAfAttribute> attributes;

    // Values section
    protected IEnumerable<CAfValue> afValues;

The only real difference are the models. I have tried to modify/shorten CAfAttribute but to no avail.
I'm clearly missing out something here...

You have two properties with same name but with different type - this code cannot be compiled.

Sorry, cut'n paste error, should be
public DateTime HistDateTimeDate { get; set; }

Try to convert the enumerable to IList:

1 Like

Yes! Of course!

Thanks for excellent support!
Ove