Hello,
I define a property in the viewmodel that is a QueryableDomainServiceCollectionView<T>. This property has change notification so that the grid that is bound to it gets notified whenever this QDSCV is changed. In the viewmodel there is a Load function that creates the EntityQuery, sets the parameters and creates a new QueryableDomainServiceCollectionView<T>. The last step in this function sets the AutoLoad to true, so that the QDSCV keeps synced with the group-, filter- and sortdescriptors.
When the user requests a refresh of the grid, then the Load function is called again. When debugging I noticed that the old QDSCV is still loading data. To resolve this I wrote the QDSCV property on the viewmodel like this:
The Cleanup-function doest the following:
This way of working resolves the issue that the grid loads the data twice from the server, but some other issues still remain. The Data_Loaded event of the RadGridView is thrown a lot of times. Ans when I debug, I can clearly see that the data involved is still data of the old QDSCV.
Is there maybe a better way to re-load data with a QDSCV? Important is that the queryparameters can be different from the previous load. So I create a new EntityQuery, and based on that I create a new QDSCV because there is no way to change the EntityQuery for the same QDSCV (is this true?).
I define a property in the viewmodel that is a QueryableDomainServiceCollectionView<T>. This property has change notification so that the grid that is bound to it gets notified whenever this QDSCV is changed. In the viewmodel there is a Load function that creates the EntityQuery, sets the parameters and creates a new QueryableDomainServiceCollectionView<T>. The last step in this function sets the AutoLoad to true, so that the QDSCV keeps synced with the group-, filter- and sortdescriptors.
When the user requests a refresh of the grid, then the Load function is called again. When debugging I noticed that the old QDSCV is still loading data. To resolve this I wrote the QDSCV property on the viewmodel like this:
private
QueryableDomainServiceCollectionView<TaskListDto> _taskListCollectionView;
public
QueryableDomainServiceCollectionView<TaskListDto> TaskListCollectionView
{
get
{
return
_taskListCollectionView; }
set
{
if
(_taskListCollectionView == value)
return
;
if
(_taskListCollectionView !=
null
) _taskListCollectionView.Cleanup();
_taskListCollectionView = value;
NotifyPropertyChanged(
"TaskListCollectionView"
);
}
}
The Cleanup-function doest the following:
public
void
Cleanup()
{
base
.Dispose();
this
.AutoLoad =
false
;
this
.GroupDescriptors.Clear();
this
.FilterDescriptors.Clear();
this
.SortDescriptors.Clear();
}
This way of working resolves the issue that the grid loads the data twice from the server, but some other issues still remain. The Data_Loaded event of the RadGridView is thrown a lot of times. Ans when I debug, I can clearly see that the data involved is still data of the old QDSCV.
Is there maybe a better way to re-load data with a QDSCV? Important is that the queryparameters can be different from the previous load. So I create a new EntityQuery, and based on that I create a new QDSCV because there is no way to change the EntityQuery for the same QDSCV (is this true?).
public
void
LoadTasks()
{
var query = _context.SearchTasksQuery(CustomerId, CurrentEmployeeId, CurrentUserId.Value, SearchString, SearchDeadline, SearchUrgent, SearchRecent, CategoryId, FinishedTasks, ShowTasksOfOthers);
TaskListCollectionView =
new
QueryableDomainServiceCollectionView<TaskListDto>(_context, query);
TaskListCollectionView.SortDescriptors.Add(
new
Telerik.Windows.Data.SortDescriptor { Member =
"SortableDeadlineDate"
, SortDirection = System.ComponentModel.ListSortDirection.Ascending });
TaskListCollectionView.GroupDescriptors.Add(
new
Telerik.Windows.Data.GroupDescriptor { Member =
"WorkflowCategoryDescription"
, SortDirection = System.ComponentModel.ListSortDirection.Ascending });
TaskListCollectionView.AutoLoad =
true
;
}