Search code examples
visual-studio-lightswitchlightswitch-2013

In LightSwitch, how do I restrict the list of choices on related tables?


I'm creating a LightSwitch app and I have a set of related tables. Warehouses have many Racks. Racks have many Shelves. Shelves have many Bins.

I've created a NewBin screen and Warehouse, Rack and Shelf appeared as drop-downs. But they contain all values. I'd like the user to be able to select Warehouse and have it show only the appropriate Racks, automatically, and then select a Rack and have it show only the appropriate Shelves.

Is this possible in LightSwitch 2013?


Solution

  • This is how I do it in LS 2012. Hope it helps.

    1. Create a query for Shelves, add a parameter, will call it X in this example
    2. Add a filter in the query, setting Rack PK = X
    3. Go to the screen designer
    4. Add the query into the designer
    5. Go to the properties window for the Shelve drop-down control
    6. Change the field "Choices:" from auto to the name of the query you created
    7. Go to the properties window for the PARAMETER you created
    8. Set the "parameter binding" for X to the correct value. E.g. Warehouse.SelectedItem.Rack.PK

    That's it.