0

On a SearchScreen, I have some properties to filter my table results.

  • ComboBox for the month.
  • ComboBox for the year.
  • ComboBox for a customer (based on a query with two parameters, DateBegin, DateEnd)

The third ComboBox need to be filtered to only show customers that are 'active' in the selected period from Month and Year Comboboxes.

I use two properties (Date) named 'prpDateBeginSelected' and 'prpDateEndSelected', linked to my query herself linked to the ComboBox of the customers.

I use the _Changed events on my Month and my Year to assignate the dates to the properties.

When I make my first selection after the screen was loaded, It work and the customer combobox is filtered in the good period. But after, when I change the month or the Year, the customers comboBox don't reload.

I've tried to do a this.qCustomersByPeriod.Refresh(); in my code but no changes.

Thanks for help.

PS : If needed, I can make you a sample to show you the idea.

EDIT : A sample to help you understand me. LS_SearchFiltered.zip (58.6 Mo)

Alex Saesee
  • 129
  • 1
  • 1
  • 11

1 Answers1

0

It's good that you provided your solution, because I got confused just from the explanation from the post. Indeed the problem with your solution was data binding. You've mistaken the data binding for QueryDataByCustomerAndPeriod.CustomerId it should be QueryCustomersByDate.SelectedItem.Id . Also instead of using generic prpCustomer, you need to use the selected item of QueryCustomersByDate and get the relevant Id. To clarify everything see the screenshots below. Hope this solves your problem.

A note to remember - check carefully your data biding in the View-Model - what links to what.

Problem in QueryDataByCustomerAndPeriod.CustomerId

Correct the binding in QueryDataByCustomerAndPeriod.CustomerId

  • Thanks Vlad, I'll read you carefully and try to do this. Back after. – Alex Saesee Aug 05 '13 at 06:25
  • Thanks Vlad. I've tried your help and don't understand all (sorry, my english is not perfect). I'll up my example with v2 : [link](http://www.saesee.net/files/developpement/LS_SearchFiltered_2.zip) Thanks again for your help. – Alex Saesee Aug 05 '13 at 07:10
  • Your are almost done, man! As I see from the solution, you configured everything properly except the prpCustomer Filter mode. You must restrict it to fulfill the where clause of the QueryCustomersByDate query. To do this - select Filter mode - Contains. Hope the screenshot clarifies everything. [link](https://dl.dropboxusercontent.com/u/25403308/AlmostDone.PNG) –  Aug 05 '13 at 12:43
  • Hi Vlad, i'v done the changes. Is it normal that if I change the year to 2000, my customer who begin in 2005 still visible (the list is not re-loaded from parameters right?). That was my main question, how to refresh the 'prp Customer' listbox ? thanks for your helpful... help :) – Alex Saesee Aug 06 '13 at 06:35
  • Well, in fact, if I enter years where data can be found, it work and filter. If I enter **1950** in the year, where no result need to be return, the list do not update and stay the same. – Alex Saesee Aug 06 '13 at 07:55
  • The solution that I proposed works for all years. You start confusing yourself from your business rules. Check your code for: **if (prpYear > 2000)** . If I disregard your prpYear and prpMonth controls, add new date time pickers bound to data begin and date end, select 1950 for begin and end date, then there are no results in the combo box. See the screenshot. [link](https://dl.dropboxusercontent.com/u/25403308/ComboBoxSolution.PNG) . And try the solution carefully before posting subsequent questions. I'm not the one to find bugs in your project. –  Aug 06 '13 at 12:19
  • Sorry if you thought to be a "bug finder", it was not my intention. I just think LightSwitch less flexible in terms of refreshing than a WPF application (and controls in my case). Thank you for your help, I will continue to establish a panel of tests to reach my goals. – Alex Saesee Aug 06 '13 at 14:08
  • So is there something left that is not working? You can still use your custom properties prpYear and prpMonth. Just in the C# code, events prpMonth_Changed() and prpYear_Changed() you must provide the appropriate values of prpDateBegin and prpDateEnd. –  Aug 06 '13 at 14:33
  • Actually not really. The concept is ok, I need to understand it better. Thanks again for your help Vlad. – Alex Saesee Aug 07 '13 at 07:16