Home Forums WPF controls Xceed DataGrid for WPF Updating ItemsSource

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

    Is there a way to force the DataGridControl to update its ItemsSource. At the moment it only seems to update the source when the user moves off a row or presses Enter to commit the changes. I’m referring to updating the bound DataTable not the backend database.

    The following command looked promising but didn’t have any effect:-
    DataGridCommands.EndEdit.Execute(null, myDataGridControl);

    I need a way to force RowValidation and commit changes when the user presses the Save button even if they haven’t moved out of a changed cell.

    Thanks
    Michael

    Imported from legacy forums. Posted by Michael (had 4619 views)

    Xceed Support
    Member
    Post count: 5658

    What you could do is to explicitly call EndEdit() on the currently edited row before processing the “Save” button logic.

    You can do so the following way:

    <code>
    Row myRow = myDataGridControl.ItemContainerGenerator.ContainerForItem( myDataGridControl.CurrentItem ) as Row;

    if( myRow != null)
    {
    myRow.EndEdit();
    }
    </code>

    Note: the EndEdit() function will throw a DataGridValidationException() if RowValidation fails.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 538 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Marcus, that worked.

    Any reason why DataGridCommands.EndEdit.Execute didn’t work?

    Michael

    Imported from legacy forums. Posted by Michael (had 462 views)

    Xceed Support
    Member
    Post count: 5658

    Long story short: Only Rows are handling the [Begin\End\Cancel]Edit commands…

    However, we are planning to extend that feature to include the DataGridControl as well (post 1.1, exact timeframe not determined yet ).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 330 views)

    User (Old forums)
    Member
    Post count: 23064

    Well, yesterday it worked and today it doesn’t work! I guess Windows is like that. 🙂
    Today myDataGrid.CurrentItem is always null (also SelectedItem). Completely baffled! Any idea what might cause this?

    Also, will the ‘Search this forum’ be fixed soon. I’d like to be able to do a search before posting questions.

    Thanks
    Michael

    Imported from legacy forums. Posted by Michael (had 447 views)

    Xceed Support
    Member
    Post count: 5658

    Hmmm, you would have to provide me with some more details on the CurrentItem and SelectedItem problem… (DataGridControl initialization code, exact steps to reproduce, …).

    Concerning the “Search this forum”… It’s been bothering us as well, and we are in the process of changing the “community” site…

    In the mean time, I can give you a workaround to using the “Search” textbox directly from the forum… Instead, go in the “Xceed Discussion Forums” root. From that page, if you use the search option… its gonna work… ( you’ll be brought to a page where it is possible to put filters on the search)

    Imported from legacy forums. Posted by Marcus [Xceed] (had 265 views)

    User (Old forums)
    Member
    Post count: 23064

    Figured it out.

    All is fine for existing rows (CurrentItem != null) but not for new rows. It seems CurrentItem and SelectedItem aren’t being set for new rows.

    …Ah, come to think of it maybe that’s because its an InsertionRow and not yet part of the DataGrid Items collection. Just a minute and I’ll try that…

    Some time later…

    Phew. That was it but finding the InsertionRow isn’t easy. In the end I defined a CustomInsertionRow and set a static Current property on it. How can I find the InsertionRow given a DataGridControl instance?

    Is there a reason for not setting CurrentItem and SelectedItem when editing in the InsertionRow?

    Presumably there should only ever be one InsertionRow per grid so can we have a property on the DataGridControl to make it easier to find?

    Thanks
    Michael

    Imported from legacy forums. Posted by Michael (had 5770 views)

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