General Question on Cascading Selections

A place for users and developers of the Xataface to discuss and receive support.

General Question on Cascading Selections

Postby danw » Fri Mar 28, 2008 4:52 am

I have a general question on various methods for using/providing selections based upon selections ( like the DEMO AUTO MPG ).

Scenario: Multiple tables regarding assets & ticketing ( yes, I'd like to build a ticketing system )

However, since a "ticket" may involve an OS, a location, a Vendor, or maybe just 1 particular piece of information. I'm left with a checkbox select for over 1800 items.

I'm looking for the "Choose X" - and then based upon X - Choice "Y" is given. At that point - either all assets with "X" are tagged, or all assets with X&Y are flagged ... etc.

I'm looking for a direction - or anyones best approach on how to handle.
I've looked through the forums - and I'm wondering if the dynamic ajax functions are the best? - - - Or has anyone tied a ticketing system into Xataface?

In advance, thanks
dan
danw
 
Posts: 9
Joined: Wed Jan 02, 2008 8:32 am

Postby shannah » Sat Mar 29, 2008 8:20 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby danw » Mon Mar 31, 2008 5:48 am

RE: 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"?

In all honesty; I'm thinking... that "Z" would already contain elements of X& Y..... Kind of like

table FOO
fooID
fooNAME <------ X
fooMODEL <----------Y
fooDESCRIPTION

concat ( X+Y+fooDESCRIPTION ) = Z

so that the initiail choices are "unique" NAME's (X) , then Based on "X" ; a concat of "X:Y" , is shown.... ( which would be a "Y" choice ) and then ultimately a concat of X:Y:Z for value Z - - - - which in turn is tied to fooID -

So your answer confirms what I was looking for , or the direction I was headed -

thanks
dan
danw
 
Posts: 9
Joined: Wed Jan 02, 2008 8:32 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved