I have the following custom sort handler in a radgrid.
For most columns, this is fine. But on occasion my datafield name is different than my object field name.
ie. a column with the following works
col.DataField = "Id";
col.UniqueName = "Id";
col.SortExpression = "Id";
but this column fails with error:
col.DataField = "DateEntered";
col.UniqueName = "DateEntered";
col.SortExpression = "OnDate";
This happens after the NeedDataSourceHandler finishes, so I am successfully getting results, and getting them into the grid. It's something internal to the grid that is failing.
NeedDataSource is pretty straight forward (it is in VB)
Am I missing something in my sort handler?
For most columns, this is fine. But on occasion my datafield name is different than my object field name.
ie. a column with the following works
col.DataField = "Id";
col.UniqueName = "Id";
col.SortExpression = "Id";
but this column fails with error:
No property or field 'OnDate' exists in type 'EvidenceEntryGridItem
col.DataField = "DateEntered";
col.UniqueName = "DateEntered";
col.SortExpression = "OnDate";
This happens after the NeedDataSourceHandler finishes, so I am successfully getting results, and getting them into the grid. It's something internal to the grid that is failing.
protected void OnSortCommand(object sender, GridSortCommandEventArgs e){ SortDirection direction = (e.NewSortOrder == GridSortOrder.Descending) ? SortDirection.Descending : SortDirection.Ascending; Sort = new SortBy(e.SortExpression, direction); GridSortExpression newSortExpression = new GridSortExpression(); newSortExpression.FieldName = e.SortExpression; newSortExpression.SortOrder = e.NewSortOrder; MasterTableView.SortExpressions.Clear(); MasterTableView.SortExpressions.Add(newSortExpression); e.Canceled = true; this.PageInfo = new GridPageInfo(1, this.PageSize); this.Rebind();}NeedDataSource is pretty straight forward (it is in VB)
Protected Sub ResultsGrid_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles ResultsGrid.NeedDataSource Dim results As EvidenceEntryGridItemResultsEnvelope = AppDomain.Instance.DI.Get(Of IEvidenceEntryGridItemRepository)().GetForUserByUniqueId(_searchValue, UserId, ResultsGrid.PageInfo, ResultsGrid.Sort, ResultsGrid.Filter) ResultsGrid.VirtualItemCount = results.TotalCount ResultsGrid.DataSource = results.Records End SubAm I missing something in my sort handler?