8 Answers, 1 is accepted
P.S. I have anothe application using xceed grid and it works fine with DataTable binding.
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
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
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
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.
Hi Miguel Peixoto,
Is it possible to send us a sample application where this problem can be reproduced?
Kind regards,
Milan
the Telerik team
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
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