LightSwitch EventHandlers

157 Views Asked by At

Developing my first real LightSwitch App.

From the main screen it drills through some hierarchical entities using detail screens until we come to a Browse screen for a particular leaf object (type 'Unit')

The chosen Unit has many date stamped 'Readings'. These readings are summarised by a DataViz chart feeding off a server controller. This all works.

I want to introduce a datetime picker into the mix.

Update the picker and it causes the chart's url property to be updated and requeries the controller.

Result being a new summary display of a new date range of Readings. That's the goal.

I add the DateTimePicker as another custom control and declare its Change Date event handler inside the pre_render code.

The DTP displays OK and its changed date event handler fires correctly.

I expected to do the magic in this handler of referencing the chart's url property and updating it with the new query string then somehow causing the controller to be requeried..

But... I can't reference the chart.

I have seen a post that LS does not expose the ids of its controls even though you declare the 'id' attribute. So possibly I am going about this the wrong way.

I get the feeling there is probably a way to bind the selected date on the dtp to a new property inside the Chart control say ':currentDate' and use this to update the URL and trigger a new call on the controller. Thereby avoiding eventHandlers. (Similar to Googles's Map API MVC implementation)

But I haven't a clue if this is correct or how to go about it.

Could someone please advise the correct way to achieve this goal. I have wandered around inside blogs and posts for many hours but can't see the way forward.

thanks

Bob

1

There are 1 best solutions below

0
On

Steve Lasker's blog entry contains all necessary information for implementing this. http://blogs.msdn.com/b/lightswitch/archive/2013/04/25/create-dashboard-reports-with-lightswitch-and-webapi-part-deux.aspx