locked
Retrive record RRS feed

  • Question

  • Hello !

    Need some help !

    I have a complex view,vwOrders, from a database that display a list of orders. I try to create a method when tap on selected line to open a new screen to edit the selected order, order that is from table Order . I try to get selected order(from primary key) but no success.  How to fix it ?

    I try the code below but result is null and should be something.

      myapp.activeDataWorkspace.mysourcedata.tblOrders_SingleOrDefault(274).execute().then(
            function (result) {
                screen.tblOrder = result;

            });

    myapp.showAddEdittblOrder(screen.tblOrder);

    Friday, June 20, 2014 4:53 PM

Answers

  • try this:
    myapp.activeDataWorkspace.ApplicationData.Customers_SingleOrDefault(1).execute().then(function (customer) {
            myapp.showAddEditCustomer(customer, {
                beforeShown: function (screen) {
                    if (customer && customer.results && customer.results.length === 1) {
                        screen.Customer = customer.results[0];
                    }
    
                }
            });
        });


    paul van bladel

    • Proposed as answer by Paul Van Bladel Tuesday, June 24, 2014 10:54 AM
    • Marked as answer by Angie Xu Wednesday, June 25, 2014 7:14 AM
    Saturday, June 21, 2014 7:58 AM

All replies

  • try this:
    myapp.activeDataWorkspace.ApplicationData.Customers_SingleOrDefault(1).execute().then(function (customer) {
            myapp.showAddEditCustomer(customer, {
                beforeShown: function (screen) {
                    if (customer && customer.results && customer.results.length === 1) {
                        screen.Customer = customer.results[0];
                    }
    
                }
            });
        });


    paul van bladel

    • Proposed as answer by Paul Van Bladel Tuesday, June 24, 2014 10:54 AM
    • Marked as answer by Angie Xu Wednesday, June 25, 2014 7:14 AM
    Saturday, June 21, 2014 7:58 AM
  • This may help:

    ...the first thing we want to do is open a new screen when the user clicks on a Order in the list.

    Click on the the Tile List control, and select the Item Tap action in the Properties for the control.

    When the Edit ItemTap Action dialog opens,  connect the screen to a new Edit screen.

    Select Choose an existing method.

    Select Orders.editSelected.

    For Navigate To, select (New Screen…) and click OK.

    See:

    An End-To-End Visual Studio LightSwitch 2013 HTML5 Application


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Sunday, June 22, 2014 12:56 PM
  • Thanks mate.

    Syntax is tricky.I was trying without ".results[0]"

    Sunday, June 22, 2014 9:34 PM
  • Thanks . This is easy when list belongs to same table. I use a viewfor list.

    Sunday, June 22, 2014 9:35 PM