This is a migrated thread and some comments may be shown as answers.

Refresh RadGridView with QueryableDomainServiceCollectionView

3 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 2
Stephen asked on 20 Apr 2011, 07:57 AM
Hi all,

I've got a RadGridView which has its ItemSource bound to View, a property on my viewmodel class of type IEnumerable. It's backed by a local variable
private readonly QueryableDomainServiceCollectionView<StandbyHoursDto_view;

EntityQuery<StandbyHoursDto> getAllStandbyHoursQuery = _allContext.GetAllStandbyCodesQuery(_jobId);
_view = new QueryableDomainServiceCollectionView<StandbyHoursDto>(_allContext, getAllStandbyHoursQuery);

It's all working as I want except when I delete a row from the context. I'm currently doing a remove on the item in the context
_allContext.EntityContainer.GetEntitySet<StandbyHoursDto>().Remove(SelectedAllLine);
which does work. I have a save button which saves the changes to the context. 
The problem I'm getting is that until I save the changes the RadGridView does not remove the deleted row from the visible rows. 
I've tried
_view.Refresh();
_view.Load();
but none seem to help. It's set to AutoLoad which works (ie changing pagesize will reload).
Hope someone can tell me how to delete a row from a RadGridView that is bound to a QueryableDomainServiceCollectionView thanks! Stephen

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 20 Apr 2011, 11:42 AM
Hello Stephen,

That is normal. You delete the entity from the context, but not from the collection. Don't do it like this. Let the collection view do the job for you. Delete the item from the QueryableDomainServiceCollectionView. This should immediately remove the row from the grid, since this is a client-side operation and the grid is bound to this collection view.

After that call the QueryableDomainServiceCollectionView SubmitChanges method. This will delete the entity from the server as well and reload the collection.

If you use this collection view you have to do all things through it and not directly on the context. 

I hope this helps.

All the best,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 2
answered on 20 Apr 2011, 11:48 AM
Thanks Ross.

I figured out finally how to get it to refresh, by, as you said doing the remove from the QueryableDomainServiceCollectionView.
I am still doing the SubmitChanges (via Save button) directly on the context, which is working. I'll have a look at changing that to use the CollectionView as well to keep it consistent.

thanks for your reply!

Stephen
0
Rossen Hristov
Telerik team
answered on 20 Apr 2011, 11:53 AM
Hello Stephen,

Actually, the QDSCV.SubmitChanges method calls the DomainContext.SubmitChanges and then makes a new Load. It's better to do everything through the QDSCV unless you want to achieve some very custom logic.

You can think of the QDSCV as a handy wrapper over the DomainContext.

Best wishes,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Stephen
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Stephen
Top achievements
Rank 2
Share this question
or