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

[Solved] Problem RadGridView + DomainDataSource. NET Ria Service, Empty Collection, the first insertion

1 Answer 197 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
thiago_zueranet
Top achievements
Rank 1
thiago_zueranet asked on 06 Aug 2009, 02:07 PM
I'm using RadGridView with DomainDataSource.

 

 

<riaControls:DomainDataSource x:Name="dds" LoadSize="40" PageSize="20" QueryName="GetPaisQuery">

 

 

 

    <riaControls:DomainDataSource.DomainContext>

 

 

 

        <ClientServ:SmartBusinessDomainContext/>

 

 

 

    </riaControls:DomainDataSource.DomainContext>

 

 

 

</riaControls:DomainDataSource>

 

 

 

 

 

 

 

<telerikGridView:RadGridView x:Name="grid" Grid.Row="1" AutoGenerateColumns="True" ItemsSource="{Binding Data, ElementName=dds}" AddingNewDataItem="grid_AddingNewDataItem"></telerikGridView:RadGridView>

 

 

 

A collection of entities of DomainDataSource is initially empty, since no record in the database! Until then fine!

The problem happens when I add a new record triggering RadGridView.BeginInsert ()

In the event AddingNewDataItem I'm doing the following:
object newEntity = (this._DataSource.Data as System.ComponentModel.IEditableCollectionView).AddNew();

 

 

 

e.NewObject = newEntity

;

 


The new line is inserted in RadGridView, but she is in a way that I can not write into the cell.

The interesting thing is that I do the same procedure, but instead of a collection of empty and contains DomainDataSource start a registry, it lets me insert a new record quietly.

What may be happening?

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 12 Aug 2009, 08:28 AM
Hello thiago_zueranet,

I'm attaching a running example base on your code snippet.
If you intend to add new default object and of course object has parameter less constructor you do not need RadGridView.AddingNewDataItem event. This event is designed to help to insert externally created objects from same type as RadGridView.ItemsSource elements. In this event you should avoid call to AddNew() method, because this method actually add item into collection and RadGridView call AddNew() internally, so you result with 2 new rows. You just need to set e.NewObject to your object.

About the editing issue, it seems that you've hit a bug in our control. The problem is that from this kind of data source RadGridView doesn't reflect correctly GridViewDataColumn.DataType property, so RadGridView cannot create proper GridViewCellEditor. This issue is logged and will be fixed with some of the next releases. I've updated your Telerik points accordingly.

Meanwhile you can set GridViewDataColumn.DataType for your columns (as shown in the example) this will enable editing.

Sincerely yours,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
thiago_zueranet
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or