Hi Dan,
With 1800 items, AJAX is definitely the best way to pursue this.
I have found it difficult to come up with a general solution for this problem because everyone's needs seem to be a little bit different.
One question is:
In your scenario where the user chooses "X" then chooses "Y", then is given some options to select (call this selection "Z"). Is there a column in your table for all of "X", "Y", and "Z", or do you only store "Z"?
If you're using 1.0, then you can override blocks and slots to add custom HTML or javascript before or after any given widget.
e.g.
before_fieldname_widget
after_fieldname_widget
fieldname_widget
E.g. if you wanted to add some custom HTML after the "location" widget you would implement the following method in the delegate class:
- Code: Select all
function block__after_location_widget(){
echo 'my html here';
}
Then spin your ajax magic.
Notice that Xataface comes bundled with an ajax library (ajaxgold - see js/ajaxgold.js) that makes ajax a snap. In addition Xataface has a "hidden" export_json action that will produce result sets as JSON objects (so that you can use them directly in javascript).
You can see what these results are like for any result set by changing your URL's -action parameter to 'export_json'.
e.g.
change index.php?-action=list&...etc...
to
index.php?-action=export_json
This will give you JSON.
To work with these results from javascript all you have to do is:
- Code: Select all
require(DATAFACE_URL+'/js/ajaxgold.js');
getDataReturnText( 'index.php?-action=export_json&...etc...',
function(text){
eval('var results = '+text+';');
// Now the results variable is an array of javascript objects
// with the results of our query.
// Suppose we have a select list with id 'myselect'
// and we want to fill the options with our results...
var select = document.getElementById('myselect');
select.options.length = 0; // empty the select list
for ( var i=0; i< results.length; i++ ){
select.options[i] = new Option(results[i].name, results[i].id);
}
});
Note that the above example assumes that the table that we are obtaining results from has a column named 'id' and 'name'.
The best way to begin experimenting is just to manually look at the format of the results of the export_ajax action.
Let me know if you want more clarification.
-Steve