Passing Values from One Widget To another Widget in Same page.

Passing Values from One Widget To another Widget in Same page.

This question has suggested answer(s)

For example:One widget(named as A)  has dropdown with values,on slection of any value in the dropdown,based on the selected value  another dropdown/grid has to be populated with values in another widget(named as B).

All Replies
  • First, is the only thing in widget A a drop down that acts upon widget B?  If so they really should not be 2 widgets.  The thought process I use is that if a widget does not provide an experience by itself, as in as the only widget on a page, then it should not be a widget.  One widget should not depend on another widget for all its functionality.

    That being said if it s a situation similar to our comment add widget and a comment list there are a couple of things you can do.

    1. If the behavior should occur immediately without a page refresh, then you should use javascript.  You can use jQuery trigger(http://api.jquery.com/trigger/) for a custom event that widget A fires and widget B handles.  Look at the Blog Create comment widget and the Blog Comments list for an example.

    If the intention is a page refresh:

    2.  Querystring.  If the data is non-sensitive(like a dropdown value would be) then just use a redirect and adjust the querystring that is read by widget B.

    #set($stringResponse = $core_v2_page.AdjustQueryString($url, $queryString))

    3.  Temp storage. You can pass data in a sort of storage bag if you will using widget storage:

    This returns a key to your data:

    #set($stringResponse = $core_v2_utility.StoreTemporaryData($data))

    Then use that key to get your data:

    #set($stringResponse = $core_v2_utility.GetTemporaryData($key))