locked
Lightswitch query shows new records yet to be saved RRS feed

  • Question

  • I have a simple screen with a one data grid showing records from a bound datasource. I also have a second datagrid on the same screen showing the result of a query. The query is based off the same datasource that the first data grid is bound to.

    If I set a filter on the query to something which returns 0 records, all is well. The first datagrid shows all the records, and the second is empty.

    Now I add a new row to the first datagrid, and begin populating the field with information.

    The newly added row now appears in the second datagrid as soon as it is created, despite the query filter conditions not being met.

    How can I stop new rows (that are yet yet to be committed to the DB) from appearing in the second datagrid (or as results from the query)?

    Thursday, December 19, 2013 9:18 AM

All replies

  • How can I stop new rows (that are yet yet to be committed to the DB) from appearing in the second datagrid (or as results from the query)?

    For newly added entities, you can't. Please read this post for an explanation (there are several other threads asking about this as well, which most direct to the following post): http://social.msdn.microsoft.com/Forums/vstudio/en-US/9ad10707-d9fd-4d84-a163-e774280e759e/how-does-ls-automatically-display-data-changes-prior-to-save-and-refresh?forum=lightswitch

    Justin Anderson, LightSwitch Development Team

    Thursday, December 19, 2013 9:25 AM
    Moderator
  • I have to agree with Kirchh that this is odd design rationale. I would have thought it be up to the developer to add the necessary logic of adding records to a filtered list, and account for such a record possibly disappearing. After all they applied/allowed the filter.

    In the application I'm working on, the idea of the filtered list on the same screen was to show existing records which possibly match information within the new record being added, in an effort to minimize duplicates (because they cant be eliminated via data integrity via table design). In the current situation the new record being added appears in the list of "possible duplicates" which will only confuse the user.....

    Putting that aside, is there not an property on the type collection object or UI control which can be set to to override the "by design" behavior ?

    Thursday, December 19, 2013 11:02 AM