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

Bug - adding new row radgridview

8 Answers 361 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ronald
Top achievements
Rank 1
ronald asked on 28 Jan 2011, 01:33 AM
Hi,

Does anyone ever experience difficulty adding new row in the radgridview? Some of the grids I'm having difficulty clicking on the "click here to add new item". It simply does not change to the edit mode.. any ideas?

thanks

8 Answers, 1 is accepted

Sort by
0
ronald
Top achievements
Rank 1
answered on 28 Jan 2011, 01:50 AM
not sure if this is a bug or not.. but it seems to be only a one way binding mode if I'm using Datatable so I needed to convert to dataview (.defaultview) to be able the radgridview adding new row.

P.S. I have anothe application using xceed grid and it works fine with DataTable binding.
0
Milan
Telerik team
answered on 28 Jan 2011, 10:26 AM

Hi ronald,

Using DataView is the preferred approach since DataView supports change notifications through interfaces like INotifyPropertychanged and INotifyCollectionChanged which are fundamental for WPF and enables our grid to sense data changes and respond accordingly.



Regards,
Milan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
ronald
Top achievements
Rank 1
answered on 29 Jan 2011, 02:55 AM
fair enough..
one more question.. the datable contains a not nullable column.. when I add the new row and do not populate the data in the not nullable column, I'm getting error Column "columnname" does not allow nulls. However when I check it again, the row was not even added to the datatable. Therefore every time I click add the new row the error "Column "columnname" does not allow nulls" always comes up.. any ideas? thanks

0
Milan
Telerik team
answered on 01 Feb 2011, 11:47 AM

Hello ronald,

Some additional logic has to be inserted into the AddingNewDataItem event to make this work correctly.

void radGridView_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
 e.Cancel = true;
 var newRow = this.dataSource.DefaultView.AddNew();
 newRow["FirstName"] = "John"; // provide default value if needed
 newRow["LastName"] = "Doe"; // provide default values if needed
 this.radGridView.ScrollIntoViewAsync(newRow,  =>
 {
  GridViewRow row = f as GridViewRow;
  if (row != null)
  {
   ((GridViewCell) row.Cells[0]).BeginEdit();
  }
 });
}



Kind regards,
Milan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Miguel Peixoto
Top achievements
Rank 1
answered on 21 Feb 2011, 12:11 PM
Hi Milan,

I'm having the a problem with the approach you gave to Ronald and hope you can help me sort this out.

When the new row enters in the mode (...BeginEdit()) and after I hit the tab key, it doesn't move to the next cell and appears to exit the edit mode.

On the other hand, if I don't use this ScrollIntoViewAsync approach, and simply call BeginInsert(), then everything seems to work ok (in what comes to moving to the next cell). But then I don't get my desired default values...

UPDATE: On more detail... I'm overriding the default return key behaviour through a custom KeyCommandProvider. Instead of CommitEdit, it moves to the next cell. When it's the last cell, then it commits the changes and creates a new row with the later approach and using ScrollIntoViewAsync.

Thanks.
0
Milan
Telerik team
answered on 24 Feb 2011, 02:21 PM

Hi Miguel Peixoto,

Is it possible to send us a sample application where this problem can be reproduced?



Kind regards,
Milan
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Yogaa
Top achievements
Rank 1
answered on 13 Oct 2015, 01:21 PM

Hi Milan,

 I am too facing a similar kind off issue with WPF radgrid, where in I have data template with a textbox in it with couple of properties binded, when I click on "Click here to add new item" (click) on pressing the tab button the textbox control gets focus it seems to be in read-only mode, how can we get focus on the (click).

I have also attached mine sample POC, kindly pls suggest an appropriate fix for this case.

To simulate the exact issue hit "Click here to add new item" and press Tab.

Also with data in the grid when we pressTab key the text within the textbox hides. how can we fix this with / without code behind (mvvm)

Thanks in advance.

Pls rename extension '.png' with'. zip'

Regards,

Yogaa

0
Stefan
Telerik team
answered on 16 Oct 2015, 10:02 AM
Hello Yogaa,


Your attachment is not visible on my side. Please note, that our ticketing system does not allow attaching projects in a forum thread. So, I would encourage you to open a new support thread and attach the sample project you referred to in it.

Best Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
ronald
Top achievements
Rank 1
Answers by
ronald
Top achievements
Rank 1
Milan
Telerik team
Miguel Peixoto
Top achievements
Rank 1
Yogaa
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or