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

Insert does not work, Delete is disabled by Devart.Data.Linq.Table<T> as ItemSource

5 Answers 194 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 1
Emil asked on 29 Apr 2010, 09:02 AM
I am evaluating your components and have tried the sample from "Tsvyatko's blog > Command Row for RadGridView with CRUD operations". I have used Devart.Data.Linq.Table<T> as ItemSource. The Insert command is enabled but does nothing, the edit is working and the delete command is disabled.
   Should the source for grid to be ObservableCollection or to implement INotifyCollectionChanged this commands to work correctly?

5 Answers, 1 is accepted

Sort by
0
Emil
Top achievements
Rank 1
answered on 30 Apr 2010, 04:30 PM
OK, I will reformulate the question. Forget Devart.

Are the commands in  RadGridViewCommands dependant from RadGridView's ItemSource and how?
0
Tsvyatko
Telerik team
answered on 03 May 2010, 09:46 AM
Hello Emil,

The problems you have encountered are related to the following:

 - Deleting - In order to enable deleting rows RadGridView first check its properties such as CanUserDeleteRows, IsReadOnly, etc. Then It tries to cast the source Collection either to ICollectionView or IList and check whether the collection is fixed size. Thus, using standard DataTable will not allowed deleting. However, it provides Property DefaultView, which is used as a proxy between the data and the control, holding all the data related to sorting, grouping and CRUD operations.

 - Adding - To successfully add new item, the the type of the Items needs to have parametless constructor (and of course ItemsSource supports adding). This restriction can be avoided by using AddingNewDataItem event by implementing custom logic. However, if the DataTable does not notify for changes when new items are added, the RadGridView, might not get notified for adding the new items.

In short, in order to perform all CRUD operations the sourceData needs to be either IList, ICollectionView or IEditableCollectionView.

Kind regards,
Tsvyatko
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
Emil
Top achievements
Rank 1
answered on 03 May 2010, 05:09 PM
"...DataTable will not allowed deleting. However, it provides Property DefaultView....."

Devart.Data.Linq.Table<TEntity> is equivalent of System.Data.Linq.Table<TEntity> and has no property DefaultView.
I have folowing:
<telerik:RadGridView x:Name="radGridView"  local:GridViewCommandRow.IsEnabled="true"    
                     ItemsSource="{Binding PagedSource, ElementName=radDataPager1}"   
                     CurrentItem="{Binding Path=MySelectedItem,Mode=TwoWay}"    
                     ShowGroupPanel="False" AutoGenerateColumns="False" ShowInsertRow="True" TabIndex="1"   
                     CanUserDeleteRows="True" CanUserInsertRows="True" IsReadOnly="False">   
....  
</telerik:RadGridView>   
<telerik:RadDataPager Grid.Row="1" AllowDrop="true"    
    x:Name="radDataPager1" PageSize="20" DisplayMode="All"   
    Source="{Binding Path=PPStundenOC}"/>   
...  
private QueryableCollectionView _PPStundenOC;  
public QueryableCollectionView PPStundenOC {  
  get {  
       if (_PPStundenOC == null)  
             _PPStundenOC = new QueryableCollectionView(ViewModelLocator.AppContext.PpMitarbeiterProjekts);  
                return _PPStundenOC;  
            }  
        }  
...  
public Devart.Data.Linq.Table<PpMitarbeiterProjekt> PpMitarbeiterProjekts 
... 

The goals here are:  
    1. Dynamic loading (in this case only 20 records on time).
    2. Sorting and filtering in grid to change direct the sql query.
    3. Fast development (bind and forget :) ).
  And these goals are achieved. The only problem are Insert and Delete command.

I have tried the same with Entity Framework. The underlaying class in this case is ObjectSet<TEntity>. The only difference is that I have one error more when the grid is not sorted and I tyr to go to another page: ""The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'."
All demos with I have found with RadGridView and Entity Framework are in ReadOnly mode.
Do you have some samples with use RadGridViewCommands and Entity Framework?

Regards
Emil

0
Accepted
Tsvyatko
Telerik team
answered on 10 May 2010, 08:30 AM
Hello Emil,

First, please excuse me the misunderstanding about Devart.Data.Linq.Table<TEntity>  equivalent.

I have prepared sample application demonstrating how command row can be used with EF. Since EF Entities does not implement none of the Interfaces that RadGridView can support, I have created QueryableCollectionView inheritor that handles the specifics about EF Queries. Please check it and let me know if this helps in your case.

Greetings,
Tsvyatko
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
Emil
Top achievements
Rank 1
answered on 11 May 2010, 04:25 PM
Perfect. Exactly what I wanted :)

I have seen that the problem was not in your controls:
INotifyCollectionChanged in Entity Framework 4.0 ?
No INotifyCollectionChanged on Table
And the same with the 'Skip' error:
virtualization

Thank you,
Emil




Tags
GridView
Asked by
Emil
Top achievements
Rank 1
Answers by
Emil
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or