Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
164
What makes my new row an old one?
posted

Hi,

I have an UltraWinGrid (Infragistics 2007) in which I want to add rows. This UltraWinGrid.UpdateMode is OnCellChange and my datasource is a Linq-to-sql object. On keydown insert, I use the AddRow() method, which creates a new row (yay!) that is invalid for the moment since I have some restrictions on my bound source (no nulls, etc.). The user can then edit the row to make it valid. As long as the user doesn't select another row, or doesn't add a new row (and edits it), my first new row doesn't seem to be submitted to my datasource. However, after selecting another row, or after editing a cell in another new row, my row appears in my ChangeSet.

My questions is "What happened when I selected the other row?". I want to know this because if I have no other rows, I can't find a way to "tell" my new row "Hey buddy, you're good to go!" (with a ctrl-enter or whatever)

Thanks,

Xavier

Parents
  • 12333
    Verified Answer
    posted

    Hi Xavier,

    The behavior you described is your typical "IBindingList" behavior.

    The WinGrid band object's AddNew( ) method actually calls the AddNew( ) of the underlying data source. This creates an instance of your object and adds it to your list. During this time, the object is set as the current object that is being edited (by the underlying data source). During this time, values can be added to the properties of your object (through the WinGrid cells). Moving focus off the current record onto another record (which also happens if you call AddNew once again) forces the currently active object to exit edit mode and be committed to the underlying data source. If there are any constraint violations, then you will get that exception (no nulls allowed, etc).

    So, how do we address this?

    There are several ways. Here are some things to keep in mind:

    • Play the game of Enable / Disable the Add button when you are currently editing one record before saving it
    • If you have a "Save" button in the toolbar, make sure you do the following:
      • theGrid.PerformAction(ExitEditMode);
      • theGrid.UpdateData( );
      • These actions force the cell values to be pushed into the underlying object's property even if the end user does not move off the cell
      • The changed underlying object gets pushed into the underlying object collection without moving off the record.
    • Play with the cool "Invalid Value Behavior" WinGrid functionality:
      • Help Topic 
      • This helps you force your end users to remain on the "bad" row until it is resolved OR canceled.
Reply Children
No Data