Problem with BeginInsert()

8 posts, 1 answers
  1. Marcin
    Marcin avatar
    28 posts
    Member since:
    Jan 2009

    Posted 23 Jun 2010 Link to this post

    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
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 23 Jun 2010 Link to this post

    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
  3. DevCraft banner
  4. Marcin
    Marcin avatar
    28 posts
    Member since:
    Jan 2009

    Posted 23 Jun 2010 Link to this post

    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
  5. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 23 Jun 2010 Link to this post

    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
  6. Marcin
    Marcin avatar
    28 posts
    Member since:
    Jan 2009

    Posted 23 Jun 2010 Link to this post

    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
  7. Scott
    Scott avatar
    16 posts
    Member since:
    Oct 2013

    Posted 28 Mar 2014 in reply to Milan Link to this post


    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.



    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.

  8. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 02 Apr 2014 Link to this post

    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.

     
  9. Scott
    Scott avatar
    16 posts
    Member since:
    Oct 2013

    Posted 02 Apr 2014 in reply to Yoan Link to this post

    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.
Back to Top
DevCraft banner