Refresh and Filter Operations - User Defined Ajax Callbacks

Description

The List control has methods that allow you to refresh the data or filter the data.

Examples 

Example 1:

{dialog.object}.refreshListData('list1')
{dialog.object}._filterList('list1','country = "usa" ');

Each of these methods causes an Ajax callback. Say you had a button on a UX that did a user-defined Ajax callback. Let's also assume that you want the button to refresh one list and filter another list. In the Javascript returned by the Ajax callback, you could certainly include the Javascript code to refresh the list and filter the other list, but then you would be triggering two additional Ajax callbacks. It would be preferable to have only a single Ajax callback. This is now possible using a new Xbasic function:

a5_UX_Action()

The following examples show how this function can be used in an Xbasic function that handles a custom Ajax callback.

Function myCallbackXB as c (e as p)

'compute the Javascript to filter a list. 
'we need to set properties in an object that will be passed to a5_ux_action()

dim ops as p
ops.Action = "Filter"
ops.filter = "country = :country and city = :city"
ops.order = "companyname desc"

'the arguments are specified in a crlf() delimited string. 
'syntax is argumentValue|||type|argumentName
ops.parameters = "UK|||c|country" + crlf() + "London|||c|city"

'specify the id of the list to filter
ops.listId = "list1"

'compute the Javascript to filter the list
'the 3rd parameter 'ajaxListAction' indicates that the UX action 
'we are going to perform is on a List. 
'the default value for this parameter is 'ajaxListAction' so in 
'this case, we could have omitted it.

dim xb as c
xb = a5_UX_Action(e,ops,"ajaxListAction")

'you can include other Javascript in the response that this callback returns. 
'for example:
xb = xb + crlf() + "alert('List was filtered');" 

myCallbackXB  = xb 

end function

Example 2:

Function myCallbackXB2 as c (e as p)

'compute the Javascript to refresh a list. 
'we need to set properties in an object that will be passed to a5_ux_action()

dim ops as p
ops.Action = "Refresh"
ops.listId = "list1"

'compute the javascript to refresh the list
dim xb as c
xb = a5_UX_Action(e,ops,"ajaxListAction")

myCallbackXB2  = xb 

end function

Example 3:

Function myCallbackXB3 as c (e as p)
'compute the Javascript to refresh data series

dim ops as p
ops.Action = "refreshDataSeries"
ops.seriesNames = "series1,series2,series3"

dim xb as c
xb = a5_UX_Action(e,ops)

myCallbackXB3 = xb 

end function