Page 1 of 1

organizing many tables

PostPosted: Thu Apr 03, 2008 2:25 pm
by ststoddard
I realize that there is some risk that the way to deal with this situation is already dealt with in the docs or prior posts, but can't recall seeing anything that will specifically do what I want, so here goes:

In my database, I have 50+ tables and growing. So this creates a mess when I open dataface, because my hand cramps by the time I scroll all the way down to find the last table in the menu at left.

Is there a better (easy) way to deal with this and allow simpler navigation to tables?

Thanks!

Steve

PostPosted: Tue Apr 08, 2008 8:04 am
by shannah
Hi Steven,

You can hide the tables menu by adding setting the 'show_tables_menu' pref to 0.

e.g.

add the following to your conf.ini file:

Code: Select all
[_prefs]
    show_tables_menu=0


Then you can create your own pull-down menu in one of the blocks. If we wanted to create a pull-down menu in the left column we could add the following to the application delegate class:

Code: Select all
function block__before_left_column(){
    $app =& Dataface_Application::getInstance();
    $tables =& $app->_conf['_tables'];
    echo '<select>';
    foreach ( $tables as $name=>$label){
        echo '<option>'.$label.'</option>';
    }
    echo '</select>';
}


Or something along those lines.

-Steve

PostPosted: Tue Aug 04, 2009 1:18 am
by Sly
Hi,

sorry to use this old thread, but I'm trying to do the exact same thing, however at the application level (not specific to one table).

Where should I put this piece of code? I tried the "index.php" at the root of my application, but this doesn't work (I think I did not understand how to implement delegate class for the entire application, and not table specific)

Or maybe it is possible to create some groups to group some tables together, and get a "Group1", Group2", etc... in the left navigation menu, with a "+" sign to display the grouped tables. This would be very nice.

thanks

PostPosted: Tue Aug 04, 2009 9:09 am
by shannah
For information on the application delegate class (a class to apply to entire app, not just one table) see http://xataface.com/wiki/Application_Delegate_Class

PostPosted: Tue Aug 04, 2009 11:54 am
by Sly
Thanks a lot Steve, this is what I was looking for.

PostPosted: Wed Aug 05, 2009 6:55 am
by Sly
This works fine, however I have now 2 other problems: I put some javascript to reload the page when a table is selected in the drop down list

- When I'm usung the "function block__custom_javascripts()" routine, it seems that the function I define in an external *.js file is unknown (at least this is what Firebug says) when it gets executed in the block__before_left_column() function. Strange...
- When I echo the javascript function directly in the block__before_left_column() routine, then the function is known, but I don't succeed in getting any value (I have "undefined" in the javascript alert)

Here is the code I have in ApplicationDelegate.php:

Code: Select all
class conf_ApplicationDelegate {
   function block__before_left_column(){
   
   echo "<script type=\"text/javascript\">
      function tableLoad(y){
      alert(y.value);
   }
   </script>";
   
   
      $app =& Dataface_Application::getInstance();
      $tables =& $app->_conf['_tables'];
      echo '<select name="ddl" onChange="tableLoad(this.value)">';
      foreach ( $tables as $name=>$label){
         echo '<option value="'.$name.'">'.$label.'</option>';
      }
      echo '</select>';
   }

/*   function block__custom_javascripts(){
      echo '<script src="javascripts.js" type="text/javascript" language="javascript"></script>';
   }
*/   
}


PostPosted: Wed Aug 05, 2009 11:56 am
by shannah
I notice that you are calling your function with parameter this.value, then your function is using y.value. Hence you are effectively alerting this.value.value which is usually undefined.

You probably just want to call your function as:
onchange="tableLoad(this)"

In addition, I'm not sure you can just get the value of a select list using a value attribute (correct me if I'm wrong). I usually get it like this:

this.options[this.selectedIndex].value

But please correct me if I'm wrong. This could be an old habit from the prehistoric days of crappy web browser javascript.

As for why it isn't recognizing your function when placed in the block__custom_javascripts() block, check the HTML output and make sure that it is outputting your javascript function. If it is then something is wrong with the javascript. If it isn't that means that something may be overriding your block definition - or it could be a bug.

-Steve

PostPosted: Tue Aug 18, 2009 6:41 am
by Sly
thanks Steve.
Changing tableLoad(this.value) to tableLoad(this) solved the problem.

Seems you indeed can get the value of the select with a value attribute :lol: