locked
'Lookup' tables and dropdown lists in Lightswitch RRS feed

  • Question

  • I'm having a little trouble figuring out how to create 'lookup tables' in LS.  By that I mean small tables used in conjunction with the main ones.  For instance, if I have an Employee table I'd like a Department table too, with a limited number of entries in it (Finance, Engineering, Marketing, etc.)

    When adding a new Employee I'd like a dropdown list to appear for the department, allowing the user to choose from one of the predefined departments. 

    What's a good way of achieving this?  I assume that (aside from the predefined ID field all LS tables get) my Department table will have DeptNumber and DeptName fields, of types Integer and String respectively. 

    I can establish the data relationship between Department and Employee without trouble, but when adding a new Employee how do I show the Department as a dropdown list?  (I'm using the HTML client right now, but I'll be doing a Silverlight client as well)

    I'm probably missing something easy, so apologies upfront.  Thanks for the help.

    Tuesday, February 18, 2014 6:17 PM

Answers

  • Ok, scratch my last question.  My problem was my Browse Departments screen was in fact a View Department screen.  In there, on the Tap Action you can't add a new Department, only edit or view. 

    So, because I was on a View Screen with nothing to view, the button to edit wasn't appearing.  Making an actual Browse Departments screen, I can put an Add Department button on there and everything works great.  Sorry for the trouble...

    • Marked as answer by Angie Xu Monday, March 3, 2014 1:35 AM
    Wednesday, February 19, 2014 12:37 AM

All replies

  • these dropdowns come immediately when you have setup the relationship correctly.

    paul van bladel

    Tuesday, February 18, 2014 6:45 PM
  • The HTML client "dropdown" is more like a "popup" actually. The Silverlight client dropdown is a real dropdown.

    Regards, Xander. My Blog

    Tuesday, February 18, 2014 10:14 PM
  • Thanks Paul.  One reason this came up is that I can't seem to create Departments in standalone fashion, which may be confusing me.  (Easily done.) 

    The relationship between the tables is a simple one to many; an Employee must have a Department, and a Department can have many Employees.

    With empty tables at the start, if I create a Browse Departments screen with an Add new department button, that button is disabled in the command bar.  However, if I create an Browse Employees screen, its Add button is not disabled.  I haven't done anything to the security on the app.

    If I stick an Add Department button on the Add Employee screen, _that_ button is not disabled.  So I can add Departments, but only if I'm in the process of adding an Employee. 

    I'm not sure if that's by design, but I can't seem to 'seed' the Department table ahead of time?

    Tuesday, February 18, 2014 10:19 PM
  • Ok, scratch my last question.  My problem was my Browse Departments screen was in fact a View Department screen.  In there, on the Tap Action you can't add a new Department, only edit or view. 

    So, because I was on a View Screen with nothing to view, the button to edit wasn't appearing.  Making an actual Browse Departments screen, I can put an Add Department button on there and everything works great.  Sorry for the trouble...

    • Marked as answer by Angie Xu Monday, March 3, 2014 1:35 AM
    Wednesday, February 19, 2014 12:37 AM