Home Forums WPF controls Xceed DataGrid for WPF Dataview cannot add or delete records

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24773 |

    This is related to the previous question I have posted.

    In order to try to simplify things as much as possible I’ve tried to create a very simple form, based purely on a single DataGrid attached to a DataView (based on a DataTable). This dataview allowed each row to be edited but did not allow records to be inserted or deleted. According to the documentation if a DataView (IBindableList) source is used and the AllowNew property is True then the DataGrid should allow insert/delete. This makes sense. But obviously I’ve missed something since I cannot add or delete records. Is there some other, possible rare, requisite that I may have missed, that might cause a Bindable DataView with AllowNew to not allow new records?

    Please forgive me if I’ve missed anything really obvious, just struggling with the whole WPF thing.

    Imported from legacy forums. Posted by Graeme (had 2041 views)

    Xceed Support
    Member
    Post count: 5658

    We used to have an issue with IBindingList and INotifyCollectionChanged interface implementations, which I am not sure if they have been corrected yet (I am at home and cannot verify for the moment).

    Do you implement INotifyCollectionChanged in your collection? If this is the case, only this interface is taken and we ignore IBindingList—resulting in the problems you are experiencing.

    I will check tomorrow to see if this issue was corrected.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2467 views)

    User (Old forums)
    Member
    Post count: 23064

    Did you ever get an answer to your question? I’ve been searching the docs, the forum and samples and cannot find a single example where a the grid is shown to simply allow a new row to be added. This should be very simple and there should be an example somewhere illustrating this very basic operation – however, if it it exists, I cannot find it.

    Imported from legacy forums. Posted by NTDeveloper (had 1002 views)

    Xceed Support
    Member
    Post count: 5658

    The IBindingList/INotifyCollectionChanged problem was fixed a while back. If you simply want to add new rows’s then you can create an empty collection (that implements IBindingList) and provide it as the source of the DataGridCollectionView to which you will bind your grid.

    By adding an InsertionRow in the headers of the grid, you will have an empty grid that allows new rows to be added.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 374 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the response;

     

    Ok, the Insertion Row is the trick. I thought you could accomplish this by just pointing the items source to a BindingList; It would sure be nice if there were a “How To” on this because none of the sample code illustrates this technique.

     

    Now, when I add the insertion row (as indicated by the code below), it always appears before the items in the list – which kinda makes sense since it is in a header. What I want is for this to behave like a standard grid and have the insertion row appear at the bottom. I tried placing it in the footer but the model doesn’t support that.

     

    <xcd:DataGridControl.View>

    <xcd:TableView UseDefaultHeadersFooters=”False” >

    <xcd:TableView.FixedHeaders>

    <DataTemplate>

    <xcd:InsertionRow />

    </DataTemplate>

    </xcd:TableView.FixedHeaders>

    <xcd:TableView.Theme>

    <xcd:AeroNormalColorTheme />

    </xcd:TableView.Theme>

    </xcd:TableView>

    </xcd:DataGridControl.View>

    Imported from legacy forums. Posted by NTDeveloper (had 778 views)

    Xceed Support
    Member
    Post count: 5658

    [quote]What I want is for this to behave like a standard grid and have the
    insertion row appear at the bottom. I tried placing it in the footer
    but the model doesn’t support that.[/quote]

    There should not be any issues adding the InsertionRow to the FixedFooters rather than the FixedHeaders.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 354 views)

    User (Old forums)
    Member
    Post count: 23064

    Ok; that worked. I guess I was just putting it in the wrong place before.

     Unfortunately, however, I cannot edit the insertion row. It appears at the bottom of the grid now but none of the fields are editable. Also, it appears in the grid even when the items source has not been specified.

     Is there not a code example somewhere that shows the various things that need to be done to accomplish this very standard operation? I’ve looked through all of the sample projects distributed with the installation package and I can’t find a single example of where a new row is added to the grid and the underlying binding list is modified. This is extremely frustrating…I’m programming this thing by trial-and-error when a simple example would really clear things up.

     

    Thanks.

    Imported from legacy forums. Posted by NTDeveloper (had 713 views)

    Xceed Support
    Member
    Post count: 5658

    Hmmm.. Something does seem to be wrong. I will investigate further and get back to you later today or tomorrow.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 762 views)

    Xceed Support
    Member
    Post count: 5658

    I have created a ticket for this case and a developer will take a look at the issue.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1506 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for looking into this.

    So is the bottom line that, for now, it is not possible to have the grid insert a record at the bottom and allow the user to edit it? Is the only alternative at this point to, for example, add an item to the underlying collection when the user clicks a button on the page?

    Imported from legacy forums. Posted by NTDeveloper (had 763 views)

    Xceed Support
    Member
    Post count: 5658

    Yes. I would think so. However, you should be able to insert into an empty grid. I will let you know as soon as I have additional information.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 468 views)

    Xceed Support
    Member
    Post count: 5658

    Can you check that all your properties in your object get/set and are initialized? In the example I sent the developers, 1 of my properties was not initialized, which was causing the same behavior you are experiencing.

     

    Imported from legacy forums. Posted by Jenny [Xceed] (had 388 views)

    User (Old forums)
    Member
    Post count: 23064

    I was never getting to the point where it created a new object at all;

     

    If you have an example of this working, I would love to see it. Could you post it here or send it to me at CMoore@GMail.com?

     

    Thank You.

    Imported from legacy forums. Posted by Chris (had 652 views)

    Xceed Support
    Member
    Post count: 5658

    Sent [:)]

    Imported from legacy forums. Posted by Jenny [Xceed] (had 452 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you very much.

     

    The problem actually turned out to be a field initialization issue as you suggested. By default, the string properties on my business objects are always null unless they are specifically set by a caller; Initializing them to the empty string allowed the fields to be edited and cause a row to be inserted as expected

    Imported from legacy forums. Posted by Chris (had 1120 views)

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.