Modal Picker Default Selection Based on Another Picker RRS feed

  • Question

  • Hi,

    Please could someone point me in the right direction for the following problem I've got in my Application.  I have two details modal pickers on a data entry screen in an app created using the Lightswitch HTML client.  The screen is for drivers to enter details of the hours they have done.  The issue I have is that I want the first modal picker (Job - table which contains details of the job the driver was assigned to for the day including the allocated vehicle ) to be selected and this action to then autopopulate a second modal picker on the screen Vehicle which selects a vehicle from the Vehicle table. 

    The relationships between the tables are all fine.  Vehicles can be allocated to a job. Vehicles can be allocated to a DriverLog. The Job can be allocated to the DriverLog also.  When the job is selected I want the vehicle to autoselect as default (to match the vehicle in the relevant job) but still be changeable by the user.

    In summary I'm looking for javascript code to allow auto selection of a modal picker which is selecting a table record (for a vehicle) based on the selected record for the same vehicle table which is  associated with the Job that is selected in the first modal window.

    The sample code is below, I've tried this amongst other things.

    myapp.AddEdittblDriverDailyLogDRIVER.created = function (screen) {
        // Write code here.
        screen.tblDriverDailyLog.addChangeListener("tblJob", function () {
            screen.tblDriverDailyLog.tblVehicle = null;
            screen.tblDriverDailyLog.tblVehicle = screen.tblDriverDailyLog.tblJob.tblVehicle;


    Hope this makes sense.



    • Edited by EdUK78 Thursday, February 13, 2014 9:18 AM Add Code
    Wednesday, February 12, 2014 12:27 PM