Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » [tip] Changing scrolling order outer/middle table
[tip] Changing scrolling order outer/middle table [message #423] Mon, 27 November 2006 09:46 Go to previous message
johandewit is currently offline  johandewit
Messages: 25
Registered: May 2006
Location: Belgium
Junior Member
Hi all,

In my specific case, in the list3 pattern, the middle table contains a list of weeknumbers, which are found in the database.

The first entry should be the latest weeknumber found in the database. This could be done using the $this->sql_orderby property, but this resulted in a a scrolling that is not so natural, because to go to a previous week, one needs to press on the next link.

So i needed to be able to display the last available week first when entering the list task.

Here is the code to achieve this.

I'm using the std.list3.inc pattern (but it should work in all similar patterns)

In the middle.table.class.inc :

function _cm_pre_getData($where, $where_array)
    {

        if ( $GLOBALS['task_id'] == "ts_in_input(list3)" )
        {
            if ( isset($_POST['reset'])  || ( ( $this->getPageNo() == 1 ) && ( ! isset($_GET['item']) ) ) )
            {

               // use a different object of $this, to avoid
               // temptering with the properties.

               // in this specifi case I retrieve all
               // weeknumbers from the database, which are passed
               // via the $whee function

                require_once 'input.class.inc';
                $test_object =& Singleton::getInstance('input');
                $test_object->sql_select = 'input_week';
                $test_object->sql_groupby = 'input_week';
                $test_object->sql_orderby = 'input_week';

                $rows= $test_object->getData_raw($where);
                $current_week = date('W');
                // Look for the weeknumber closest to the 
                // current week to be the default

                foreach ($rows as $index =>$val_array)
                {
                    if ($val_array['input_week'] >= $current_week)
                    {
                        break;
                    }
                }
                $this->setpageNo($index+1);
            }
        }
        return $where;
    }



I hope it is clear and it is useful for someone. I've attached a screendump where you can see the first screen displays the last week found in the middle table.

Greetings

Johan

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New Application
Next Topic: Concurrency / freshness of data objects
Goto Forum:
  


Current Time: Sat Nov 23 16:17:58 EST 2024

Total time taken to generate the page: 0.01192 seconds