locked
Adding related, related data to a LightSwitch HTML Screen RRS feed

  • Question

  • I have three tables that are related:

    • WorkInstructions has many DataTableHeaders
    • DataTableHeaders has many DataTableValues

    I want to have a view WorkInstruction screen that shows a ListView of DataTableHeaders. Inside of the each list item, I want to show a table of DataTableValues that are related to the DataTableHeaders. 

    Right now my relationships are set up correctly in the entity designer. When I add a WorkInstruction to the screen, I click the Add DataTableHeaders link in the WorkInstruction property list. I get a set of DataTableHeaders related to the WorkInstruction. Then in the DataTableHeaders collection I click the Add DataTableValues to add the related DataTableValues. I drag the Headers into the view and I get a nice list of Headers within my WorkInstruction. I then drag the Values table in as a child to Headers and change it to Grid.

    When I run the solution, I see my Headers just fine in the WorkInstruction, but nothing in the Values tables under each one. I have to click on one of the Headers list view items then the Values table loads, but it loads the same data for all Header instances.

    I know this is convoluted, but I think it has something to do with related data. The Values are only loading for the currently selected Header on the screen. I tried to add the data to the Headers collection through Manage Included Data, but that's not an option: it only shows WorkInstructions as something to manage.

    I'm basically trying to show two "levels" deep of related data. I can do all of this manually through a custom control, but I'd really just like LightSwitch to manage it for me :)

    Any ideas?

    Tuesday, October 14, 2014 9:10 PM

All replies

  • This would work for most cases. I'm being driven by some customer requirements to show the data all in one long page. They don't want to tap on anything to open up data; they just want to see the data all at once. 

    Customers ;)

    Anyways, There is probably an easier method to this using OData. I'd like to simply query the built in OData endpoints with the client API. There is just one problem; I can't figure out how to use orderBy for related entities. 

    I have a one-to-many relationship (a header has many value entities) and I want to show the data from the header and then have each value entity in my OData. There is a field of the value entity called "Order". I want the value entities to be sorted by the Order field, not by the Identity field.

    Any idea on how to do that? I can't even it work in my browser by calling to the OData endpoints, so it may not be supported in LightSwitch's OData implementation.

    Thursday, October 16, 2014 5:46 PM
  • I don't have any examples :(

    Until I have done something and blogged on it, I really don't know for sure it will work :(


    Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book

    http://LightSwitchHelpWebsite.com

    Thursday, October 16, 2014 7:22 PM
  • It seems that the HTML client only loaded the related, related data when you put the furthest child of data on the screen.

    I have a work around that involves creating a query for my values (the furthest child in the relational data) and telling LightSwitch to include the parent data through Manage Included Data. Then I added the query to the screen and told it to not be visible. After the page loads, then the data is available in the "screen" parameter when running a function or render code.

    Seems like something that should be added to a new version of LightSwitch :) I think that having the ability to cascade all the way down the relational chain in your DB can be a good thing if you want access to all your data straight away when the screen is created. I'd imagine the logic for it not being included is that these apps were intentional meant for "mobile" use where data access can be kind of hard sometimes.


    Thursday, October 16, 2014 7:28 PM