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

Problem with BeginInsert()

7 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Marcin asked on 23 Jun 2010, 09:43 AM
Hello.

I have a problem with inserting new row. Calling method BeginInsert() doesn't work. Default shortcut "F1" doesn't work too. It was worked, if itemssource was localy defined. I have local class, and I've created a List<localClass>. When I change itemssource on Web Service, this doesn't work. I see data in RGV, but I can't insert inplace methode.
Unfortunatelly I can't do example for you, because with local structure it is working.

Regards,
Marcin

7 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 23 Jun 2010, 09:46 AM
Hello Marcin,
Please make sure your source collection implements either IList, or IEditableCollectionView.
Not implementing one of these interfaces is the most common reason for RadGridView not being able to insert new item

Greetings,
Pavel Pavlov
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
Marcin
Top achievements
Rank 1
answered on 23 Jun 2010, 09:54 AM
Hello Pavel.

For itemssource I set System.Collections.Generic.List of my object. I think, that is correct. Should I do something more? This structure was always working, but I use "in place insert" first time in SL.

Greetings,
Marcin
0
Accepted
Milan
Telerik team
answered on 23 Jun 2010, 10:19 AM
Hello Marcin,

BeginInsert() might not also work when the data items do not have a public parameterless constructor - in such situations the grid cannot create new item and respectively insert it in the source collection. If that is the case you can use the AddingNewDataItem event to manually construct new objects.

More information on this topic can be found here.


Sincerely yours,
Milan
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
Marcin
Top achievements
Rank 1
answered on 23 Jun 2010, 10:45 AM
Thanks for suggestion.
Localy I have List<class> and it was OK. From Web Service I recived List<struct> and it doesn't work. So I changed struct to class and everything is OK.

Regards,
Marcin
0
Scott
Top achievements
Rank 2
answered on 28 Mar 2014, 06:34 PM
[quote]

BeginInsert() might not also work when the data items do not have a public parameterless constructor - in such situations the grid cannot create new item and respectively insert it in the source collection. If that is the case you can use the AddingNewDataItem event to manually construct new objects.[/quote]

I have the same issue.  I wanted to use a button click event to add a new item in my GridView.  So in the click handler I call the BeginInsert() of my GridView and nothing happens.  I've set breakpoints and debugged and it never even goes into the AddingNewDataItem event handler.  The weird thing is that I have 2 GridViews, but 1 works and 1 doesn't.  They are both identical in terms of XAML properties and both have an ObservableCollection<class> for their ItemsSource where each class has a parameterless constructor.

I would add that before I tried to use the button click to trigger the new item, I was using the ShowInsertRow="True" property of the GridView to where it has that first row that says, "Click here to add a new item,and on the GridView that works, it would add the new item with one click.  However, the GridView that doesn't currently work, it required me to click that row 2 times before it would add the new item.  I'm not sure if this has something to do with why the BeginInsert() doesn't work for the button, but it definitely was the reason I moved to the button.

0
Yoan
Telerik team
answered on 02 Apr 2014, 03:21 PM
Hi Scott,

I've tried to reproduce your problem, but to no avail. I have attached my test project for a reference. Could you check it and modify it in order to demonstrate the issue? 

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Scott
Top achievements
Rank 2
answered on 02 Apr 2014, 09:31 PM
I ended up taking a look at my XAML and saw something that I thought might be wrong.  I found out that the issue was that I had one of my columns as a GridViewColumn when it should have been a GridViewDataColumn since it had a DataTemplate with a control that was Binding to a property on the Row Item.  Once I changed it do a GridViewDataColumn things worked as expected.
Tags
GridView
Asked by
Marcin
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Marcin
Top achievements
Rank 1
Milan
Telerik team
Scott
Top achievements
Rank 2
Yoan
Telerik team
Share this question
or