When my datagrid loads, the newrow row is not showing. It only shows after I click on one of the headers. After that it works fine, and correctly adds new records. I'm using the express 2008.2 version. Here's my current code:
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AllowAddNew="True" AllowDelete="True" SummaryDescriptionVisibility="Collapsed" AutoGenerateFields="False" HighlightAlternateRecords="True" GroupBySummaryDisplayMode="Default" AddNewRecordLocation="OnBottom" />
</igDP:XamDataGrid.FieldLayoutSettings>
Hello,
It is really odd that it does not work correctly ( especially with ObservableCollections ) and probably it is due to the way of binding. I have attached project with simple binding. Please take a look at it and notify us if this solution can be of some help to you.
I tried your sample. The first time when I load the window, nothing shows up. Once I click on the button, the data is available and everything works fine.
What my requirement is that I need to show up a blank grid (with an empty bindinglist object) with the Add New Row, so that the user can start adding records to the grid. I am facing problem that in such scenarios, the grid is blank without the Add New Row.
Any suggestions will be appreciated.
I suggest using collections that implement IEditableCollectionView Interface. Here is an article about them: http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditablecollectionview.aspx
and
http://blogs.msdn.com/vinsibal/archive/2008/05/20/wpf-3-5-sp1-feature-ieditablecollectionview.aspx
Using that I think there should be no problem in showing a blank grid with the AddNewRow indicator visible.
Alex.
I tried the collections that implement that interface (as in the code snippet below), but still have the same problem.
WorkingList1 = new BindingList<DeleteableChar>();WorkingList2 = new BindingListCollectionView(new BindingList<DeleteableChar>());WorkingList3 = new ListCollectionView(new List<DeleteableChar>());
I have attached a sample with three grids bound to three different collection types. When loaded, none of the AddNew rows are visible. If you resize the window though, the AddNew rows then show up.
Alex/Infragistics, are you able to reproduce the problem with the samples uploaded?
Hi,
We reproduced the situation but cannot determine whether this is incorrect behavior or is just missed scenario. I can offer you a workaround or you can submit it as a request.
The workaround is :
1) remove from the grid:
AllowAddNew="True" AddNewRecordLocation="OnTopFixed"
2) Add a blank dummy element in the collection:
WorkingList1.Add(new DeleteableChar());
3) Handle the RecordUpdated event like this:
private void CharacteristicsGrid_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e) { CharacteristicsGrid.FieldLayoutSettings.AllowAddNew = true; CharacteristicsGrid.FieldLayoutSettings.AddNewRecordLocation = Infragistics.Windows.DataPresenter.AddNewRecordLocation.OnTopFixed; }
Hope this helps and is appropriate in your scenario,
Thanks Alex. I submitted it as a support request. Unfortunately, adding a blank dummy element to the list will not work in my scenario, as we need to track any and all changes made by the user to the underlying collection.
Is it possible to make ObservableCollection working for add new row in DataGrid?
-Vivek
I think one needs to add AllowAddNewDefault="Yes" property inside DisplayLayout.
I have the same problem. We've been living it with it for a while now. Low priority, but I reported this over a year ago.