Welcome, Guest
Username: Password: Remember me

TOPIC: SELECT Box Limits override

SELECT Box Limits override 01 Sep 2014 09:16 #12606

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
For some reason, SELECT boxes based on Foreign Keys are limiting the items in the drop-down by the limit users set in filters and searches

This means that if a user was to set search limits to 20, and I have more than 20 items in a SELECT BOX, the select box is rendered useless as I need it to list all items.

How do I hardcode a select box to NOT have a limit?

Thanks
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

SELECT Box Limits override 03 Sep 2014 09:37 #12609

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Anyone? I am sure I can be the only one who has come across this
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

SELECT Box Limits override 15 Sep 2014 11:19 #12629

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
When you want to separate limits behaviors from one page to another, you must specify a unique 'context' name to the model.

prepareQuery() handle different SQL for different contexts
But ALSO the engine stores the states in different places. Doing this, your ajax combos for instance will not be afected by the filters applied on that table, from a previous navigation page.
Every states are separated by their 'context'
$model->setContext('myNew.FreeName Context');
$items = $model->getItems();

In prepareQuery, you can build twice the same SQL for 2 different contexts (just add your new context to an existing case in that function)

Note for me... A doc could be nice on that topic.

Does it helps you ?
Coding is now a piece of cake
The administrator has disabled public write access.

SELECT Box Limits override 16 Sep 2014 09:02 #12630

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
I was able to remove the limit by forking the populateState function for the model and modifying it with
$this->setState('list.limit', 0);

The final populate state was
public function populateState($ordering = null, $direction = null)
    {
        // Initialise variables.
        $app = JFactory::getApplication();
        $session = JFactory::getSession();
        $acl = RtiprintHelper::getActions();

        parent::populateState('a.ordering', 'asc');

        //Only show the published items
        if (!$acl->get('core.admin') && !$acl->get('core.edit.state'))
            $this->setState('filter.published', 1);
            $this->setState('list.limit', 0);
    }

}
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

SELECT Box Limits override 16 Sep 2014 12:45 #12635

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
This is the right solution if it applies for ALL calls.

Your pagination system will be broken on regular lists.
If you don't mind, that's ok.

As I told you before, if you use another context, then it separates the states collections.
You can also set it for all contexts by default, and activate the limit only for regular lists (the natives ones in your generated component)
Coding is now a piece of cake
The administrator has disabled public write access.

SELECT Box Limits override 16 Sep 2014 12:47 #12636

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
By the way, Morgan

Can you please update your email address, because since a long time your mails notifications returns to me as invalid mail address.
Nothing really important, but it is preferable for you too.
Thanks.
Coding is now a piece of cake
The administrator has disabled public write access.

SELECT Box Limits override 25 May 2015 20:55 #13182

Hi!

I'm using the stable version of builder (Stable 2.7) ... but after the new site upgrade, I'm having strange issues with "mycontext.modal" case in the prepareQuery model's method. :side:

Before the updgrade, i could write a fork with the following instructions:
switch($this->getState('context', 'all'))
		{
			case 'contatore.default':
				...
                                break;

			case 'contatore.modal':

				//BASE FIELDS
				$this->addSelect(	'a.matricola');
                                $this->setState('list.limit', null);
				break;

			case 'all':
				...
				break;
		}

and the "modal" context was set by default, when populating data for a list in an item view. So it was sufficient define a FK model like this:
$model_contatore_divisionale = CkJModel::getInstance('Contatore', 'LettintemporipartiModel');
$model_contatore_divisionale->addGroupOrder("a.matricola");
$lists['fk']['contatore_divisionale'] = $model_contatore_divisionale->getItems();

Now, the "modal" context is not set by default, so I had to specify it manually (as following):
$model_contatore_divisionale = CkJModel::getInstance('Contatore', 'LettintemporipartiModel');
$model_contatore_divisionale->setState('context', 'contatore.modal');  
$model_contatore_divisionale->addGroupOrder("a.matricola");
$lists['fk']['contatore_divisionale'] = $model_contatore_divisionale->getItems();

Nevertheless, "$this->setState('list.limit', null)" seems to do anything. I tried to use JLog functions to test del "modal" case and it works, but no limit is set!

So I tried to use the populateState method as morganleecy did, but no luck!!
public function populateState($ordering = null, $direction = null)
	{
		// Initialise variables.
		$app = JFactory::getApplication();
		$session = JFactory::getSession();
		$acl = LettintemporipartiHelper::getActions();
                
                parent::populateState('a.matricola', 'asc');
                
                $this->setState('list.limit', 0);    //THIS WORKS FOR ALL, OBVIOUSLY
                
                if($this->context == "contatore.modal")
                {   
                    JLog::add("WHY NOT?", 'jerror');
                    $this->setState('list.limit', 0);   //THIS DOESN'T WORK  :(((  WHY NOT?
                }
	}
The second setStaste doesn't work, and I really don't figure how...because the error "WHY NOT?" is printed...

Where i miss?
The administrator has disabled public write access.

SELECT Box Limits override 28 May 2015 22:23 #13189

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I think everything is ok.

For me, the modal states works like a charm.
The problem is maybe because the states are modified again AFTER populateState()
in prepareQuery(), the list.limit state is modified again.

Also, why do you try to apply a 'modal' state to your FK ? Just for test ?
Coding is now a piece of cake
The administrator has disabled public write access.

SELECT Box Limits override 11 Jun 2015 14:48 #13259

I need that the list of FK is NOT limited to 20 items... but i have to view ALL items.

Now I can have the same result by setting the filter VIEW=ALL in the collection view, and than while creating new item, the FK fill's with all items. But so the collection view load all items too, resulting very slow.

So i need to have the limit set on 20 in the collection, and NO LIMIT in the FK collection items.

How can obtain this?
The administrator has disabled public write access.

SELECT Box Limits override 22 Jun 2015 07:39 #13293

Please Admin, help meeeeeee! :(
The administrator has disabled public write access.
Time to create page: 0.066 seconds

Get Started