locked
OnClick event Handler ?

    Question

  • I have a two column screen with the left side populated by a summary list of companies with account_ids. On the right I have a non related table that also has an account_id field. I am wondering what and where the event handler is for the click event on the left grid so that I can pass the account_id to the right grid.

    I have accomplished this functionality using a button, but I would like to eliminate that button press in favor of an OnClick event.

    Any help would be appreciated. Thanks.


    Shane Ledford
    Tuesday, November 02, 2010 9:38 PM

Answers

  • LightSwitch does not provide any UI events for you to handle. All of the events you can handle are data model or screen data events. It's possible to handle UI events by subscribing handlers to UI controls, but LightSwitch does not present this in an upfront way because it encourages writing code without having to depend the specific implementation of UI controls.

    Even though you say that the two entity collections that you have on the the screen are not related, you can bind the parameters of the collection on the right (the child collection) to the selected item of the collection on the left (the parent collection). By doing this, when the user of the application selects a row in the list or grid on the left, then the list or grid on the right will update automatically with "related" entities.

    • Marked as answer by Shaneledford Wednesday, November 03, 2010 1:38 PM
    Wednesday, November 03, 2010 6:17 AM
  • That's exactly what I need to accomplish. Could you go into more detail about how I would bind the two non-related collections ?

    Right now I have a screen variable called account_id and a query parameter on the child collection set equal to the variable. I have a button that passes the account_id of the selected item in the parent collection to the screen variable. How can I bind these two tables without the button press ?

     

    EDIT: of course just as I respond I figure it out. For anyone else who might need this, this how to do it.

    Click the query parameter of the child collection and change Parameter Value to <parentCollection>.SelectedItem.account_id


    Shane Ledford
    • Marked as answer by Shaneledford Wednesday, November 03, 2010 1:39 PM
    Wednesday, November 03, 2010 1:32 PM

All replies

  • LightSwitch does not provide any UI events for you to handle. All of the events you can handle are data model or screen data events. It's possible to handle UI events by subscribing handlers to UI controls, but LightSwitch does not present this in an upfront way because it encourages writing code without having to depend the specific implementation of UI controls.

    Even though you say that the two entity collections that you have on the the screen are not related, you can bind the parameters of the collection on the right (the child collection) to the selected item of the collection on the left (the parent collection). By doing this, when the user of the application selects a row in the list or grid on the left, then the list or grid on the right will update automatically with "related" entities.

    • Marked as answer by Shaneledford Wednesday, November 03, 2010 1:38 PM
    Wednesday, November 03, 2010 6:17 AM
  • That's exactly what I need to accomplish. Could you go into more detail about how I would bind the two non-related collections ?

    Right now I have a screen variable called account_id and a query parameter on the child collection set equal to the variable. I have a button that passes the account_id of the selected item in the parent collection to the screen variable. How can I bind these two tables without the button press ?

     

    EDIT: of course just as I respond I figure it out. For anyone else who might need this, this how to do it.

    Click the query parameter of the child collection and change Parameter Value to <parentCollection>.SelectedItem.account_id


    Shane Ledford
    • Marked as answer by Shaneledford Wednesday, November 03, 2010 1:39 PM
    Wednesday, November 03, 2010 1:32 PM
  • That's exactly what I need to accomplish. Could you go into more detail about how I would bind the two non-related collections ?

    Right now I have a screen variable called account_id and a query parameter on the child collection set equal to the variable. I have a button that passes the account_id of the selected item in the parent collection to the screen variable. How can I bind these two tables without the button press ?

     

    EDIT: of course just as I respond I figure it out. For anyone else who might need this, this how to do it.

    Click the query parameter of the child collection and change Parameter Value to <parentCollection>.SelectedItem.account_id


    Shane Ledford


    LightSwitch Team:

    Please note that I originally did what Shaneledford describes in my LightSwitch Attendance application:

    http://lightswitch.adefwebserver.com/Blog/tabid/61/EntryId/10/LightSwitch-Student-Information-System-Part-3-Custom-Controls.aspx

    I did not want people to have to click the button to get Attendance. The original way I had it, was that the query that pulled up the Attendance for each day was bound to the Day selected.

    This worked 90% of the time... so ummm that was not gonna cut it :)

    The error was that when you changed Attendance, moved to a new day and moved back, it would not see your changes. it is as if you only got the cached copy not the committed records. I even put in some calls to "Refresh()" but still got old data.

    Putting a button on the page that explicitly retrieved the Attendance for the day, solved the problem.


    http://www.adefwebserver.com

    http://lightswitch.adefwebserver.com

    Wednesday, November 03, 2010 5:38 PM