Cannot sort or filter when using Radzen grid Column template

Hi Support,

I'm taking over a project from another developer. So I'm a newbie to the Radzen component, so be nice to me.
In this project there is a nested grid that has sorting and filtering options, but this only works if the column is not a template. The header to the template column has no filter or sorting only title is showing.

So my problem is how to make sure that all columns have options for filtering and sorting. This applies especially to columns with Template. Have I missed something?

This is the property that holds the data

public IEnumerable<Versioned<FrameAgreement>> VersionedSearchResult { get; set; }

Here are the dtos

    public class Versioned<T>
    {
        public Versioned(T currentVersion, IEnumerable<T> oldVersions)
        {
            CurrentVersion = currentVersion;
            OldVersions = oldVersions;
        }

        public T CurrentVersion { get; }
        public IEnumerable<T> OldVersions { get; }
    }

Here are the object

    public class FrameAgreement : IIncentive
    {
        public FrameAgreement(Guid id, string approverLoginName, string attachmentUrl, DateTime? archiveDate, Guid? cesarConditionTypeId, int classificationCode, string comments, string companyName, string frameAgreementCode, bool isManual, string primaryOrganisationNumber, string relevantDateType, string status, string type, DateTime? validFrom, DateTime? validTo, int? version, string validationType, byte[] timeStampDw, string information)
        {
            Id = id;
            ApproverLoginName = approverLoginName;
            AttachmentUrl = attachmentUrl;
            ArchiveDate = archiveDate;
            CesarConditionTypeId = cesarConditionTypeId;
            ClassificationCode = classificationCode;
            Comments = comments;
            CompanyName = companyName;
            FrameAgreementCode = frameAgreementCode;
            IsManual = isManual;
            PrimaryOrganisationNumber = primaryOrganisationNumber;
            RelevantDateType = relevantDateType;
            Status = status.ToEnumOrDefault<IncentiveStatus>();
            Type = type;
            ValidFrom = validFrom;
            ValidTo = validTo;
            Version = version ?? 1;
            ValidationType = validationType;
            TimeStampDw = timeStampDw;
            Information = information;
        }

        public Guid Id { get; }
        public string ApproverLoginName { get; }
        public string AttachmentUrl { get; }
        public DateTime? ArchiveDate { get; }
        public Guid? CesarConditionTypeId { get; }
        public int ClassificationCode { get; }
        public string Comments { get; }
        public string CompanyName { get; }
        public string FrameAgreementCode { get; }
        public bool IsManual { get; }
        public string PrimaryOrganisationNumber { get; }
        public string RelevantDateType { get; }
        public IncentiveStatus Status { get; }
        public string Type { get; }
        public DateTime? ValidFrom { get; }
        public DateTime? ValidTo { get; }
        public int Version { get; }
        public string ValidationType { get; }
        public byte[] TimeStampDw { get; }
        public string Information { get; }
    }
    <RadzenGrid ColumnWidth="200px" Count="@VersionedSearchResult.Count()" Data="@VersionedSearchResult" AllowColumnResize="true" 
                              AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="@pageSize" 
                              TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>">
        <Template Context="versionedFrameAgreement">
            <RadzenGrid  Data="@versionedFrameAgreement.OldVersions" TItem="VSSI.API.Shared.Dtos.FrameAgreement" AllowSorting="true" AllowFiltering="true">
                <Columns>
                    <RadzenGridColumn Property="FrameAgreementCode" TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["FrameNumberColumn"])">
                        <Template Context="data">
                            <div style="cursor:pointer;font-weight:bold;" @onclick="@(()=>FrameAgreementNameClicked(@data.Id.ToString()))">@data.FrameAgreementCode</div>
                        </Template>
                    </RadzenGridColumn>
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["CompanyNameColumn"])" Property="CompanyName" />
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["PrimaryOrganisationNumberColumn"])" Property="PrimaryOrganisationNumber" />
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Width="100px" Title="@(localizer["TypeColumn"])" Property="Type" />
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Width="100px" Title="@(localizer["StatusColumn"])" Property="Status" />
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Width="100px" Title="@(localizer["VersionColumn"])" Property="Version" />
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["ValidFromColumn"])" Width="100px">
                        <Template Context="data">
                            @(data.ValidFrom.HasValue ? data.ValidFrom.Value.ToShortDateString() : "N/A")
                        </Template>                        
                    </RadzenGridColumn>
                    <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["ValidToColumn"])" Width="100px">
                        <Template Context="data">
                            @(data.ValidTo.HasValue ? data.ValidTo.Value.ToShortDateString() : "N/A")
                        </Template>
                    </RadzenGridColumn>
                </Columns>
            </RadzenGrid>
        </Template>
        <Columns>
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Title="@(localizer["FrameNumberColumn"])">
                <Template Context="data" >
                    <div style="cursor:pointer;font-weight:bold;" @onclick="@(()=>FrameAgreementNameClicked(@data.CurrentVersion.Id.ToString()))">@data.CurrentVersion.FrameAgreementCode</div>
                </Template>
            </RadzenGridColumn>
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Title="@(localizer["CompanyNameColumn"])" Property="CurrentVersion.CompanyName" />
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Title="@(localizer["PrimaryOrganisationNumberColumn"])" Property="CurrentVersion.PrimaryOrganisationNumber" />
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Width="100px" Title="@(localizer["TypeColumn"])" Property="CurrentVersion.Type" />
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Width="100px" Title="@(localizer["StatusColumn"])" Property="CurrentVersion.Status" />
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Width="100px" Title="@(localizer["VersionColumn"])" Property="CurrentVersion.Version" />
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Title="@(localizer["ValidFromColumn"])" Width="100px">
                <Template Context="data">
                    @(data.CurrentVersion.ValidFrom.HasValue ? data.CurrentVersion.ValidFrom.Value.ToShortDateString() : "N/A")
                </Template>
            </RadzenGridColumn>
            <RadzenGridColumn TItem="VSSI.API.Shared.Dtos.Versioned<VSSI.API.Shared.Dtos.FrameAgreement>" Title="@(localizer["ValidToColumn"])" Width="100px">
                <Template Context="data">
                    @(data.CurrentVersion.ValidTo.HasValue ? data.CurrentVersion.ValidTo.Value.ToShortDateString() : "N/A")
                </Template>
            </RadzenGridColumn>
        </Columns>
    </RadzenGrid>

Hi @jono,

In order to have sorting and filtering you need to set Property for this column. Check also our dynamic data example, might help you in your case:
https://blazor.radzen.com/datagrid-dynamic

Hi @enchev ,
There is a Property set on the RadzenGridColumn to the first column in the grid or is it not here you mean?

                   <RadzenGridColumn Property="FrameAgreementCode" TItem="VSSI.API.Shared.Dtos.FrameAgreement" Title="@(localizer["FrameNumberColumn"])">
                        <Template Context="data">
                            <div style="cursor:pointer;font-weight:bold;" @onclick="@(()=>FrameAgreementNameClicked(@data.Id.ToString()))">@data.FrameAgreementCode</div>
                        </Template>
                    </RadzenGridColumn>

The first column indeed does have Property set. None of the other columns that use templates have it though. You can use our demo for a reference.

Hi @korchev,

When I have giving all tempalte a Property the filter and Sorting icon shows, but I reciving an error.
*Error: No property or field 'FrameAgreementCode' exists in type 'Versioned`1' (at index 1)

This issue seems to be about the Property statement that I have written now. Could it be missing something?

Hello again,
Sorry I've taken up all your time I've found my fault. A classic copying error.
For the last grid, I just copied the property value from the first grid and forgot to add CurrentVersion.

Thanks for all the help

Kind regards
Jörgen