Zen Pages: How to update table pane using javascript event handler
Hi, I am creating a zen page which has a table pane, and loads data, using the onCreateResultSet. I have two controls which allows the user to add a date and type.
I want to add them as parameters into my sql query and update the tablepane. Can you advice on how I can do that?
{
// i can get the values from my controls here
var par1 = zenPage.
// how can I insert this value par1 and write a new sql query using the value above and update the tablepane
}
I generally don't use OnCreateResultSet, but here's a sample with it:
And the data behind it (minus storage definition):
This also demonstrates how to securely add multiple filters to a query - using the ? syntax, *not* just concatenating strings in directly. The "variadic arguments" syntax where you pass in an integer-subscripted array to be any number of arguments (including 0) is super handy for this.
That worked a charm Timothy, thank you. Can I ask, if I want to add an additional date field, how can I add a between clause in the createSearchResult set method? so
Where name starts with
And Somedate BETWEEN ?(datefilter1) and ?(datefilter2)
Here's an updated example for that. I've also updated the example to use %SQL.Statement, which is newer and better than %ResultSet; I didn't realize it would work with OnCreateResultSet initially.
Note - I got something slightly wrong in the original example. The responsibility of OnCreateResultSet is just to create the ResultSet, not to execute the query. Most importantly, the parameters in the QueryInfo object need to be reset to just the subset used in our method of generating the query; otherwise, the original parms array would be used to execute the query, which could produce incorrect results (but didn't happen to in the simpler example). An alternative approach would be adding a server-side callback for ExecuteResultSet as well, but in this case it's simpler to just manipulate the parms array.
Thank you for this Timothy. Goes a long way.. so clear and able to understand well.