Welcome, Guest
Username: Password: Remember me

TOPIC: Set ordering of combo-box items

Set ordering of combo-box items 06 Mar 2013 18:40 #6920

  • jhallock
  • jhallock's Avatar
  • Offline
  • Senior Member
  • Posts: 43
  • Thank you received: 1
  • Karma: 0
I have this function which was created by j-cook in my view.html.php file. I want the items in the generated list to be sorted by "title". How do I do this? Thanks!
protected function displayAjax($tpl = null)
	{
		$jinput = new JInput;
		$render = $jinput->get('render', null, 'CMD');
		$token = $jinput->get('token', null, 'BASE64');
		$values = $jinput->get('values', null, 'ARRAY');



		switch($render)
		{
			case 'filter1':
				$model = $this->getModel();
				$items = $model->getItems();
				
				/* Ajax Filter : client > STUDY
				 * Called from: view:progressreports, layout:default
				 * Group Level : 0
				 */

				$selected = (is_array($values))?$values[count($values)-1]:null;


				$event = 'jQuery("#filter_study").val(this.value);submitform();';
				echo "<div class='ajaxchain-filter ajaxchain-filter-hz'>";
				echo "<div class='separator'>";
				echo JDom::_('html.form.input.select', array(
					'dataKey' => '__ajx_study',
					'dataValue' => $selected,
					'formControl' => null,
					'list' => $items,
					'listKey' => 'id',
					'labelKey' => 'title',
					'nullLabel' => "CFMC_JSEARCH_SELECT_STUDY",

					'selectors' => array(
										'onchange' => $event
									)
					));
				echo "</div>";
				echo "</div>";



				break;

			case 'groupby1':
				$model = $this->getModel();
				$items = $model->getItems();
				/* Ajax Chain : client > STUDY
				 * Called from: view:progressreport, layout:editprogressreport
				 * Group Level : 0
				 */

				$selected = (is_array($values))?$values[count($values)-1]:null;


				$event = 'jQuery("#jform_study").val(this.value);';
				echo "<div class='ajaxchain-filter ajaxchain-filter-hz'>";
				echo "<div class='separator'>";
				echo JDom::_('html.form.input.select', array(
					'dataKey' => '__ajx_study',
					'dataValue' => $selected,
					'formControl' => 'jform',
					'list' => $items,
					'listKey' => 'id',
					'labelKey' => 'title',
					'nullLabel' => "CFMC_JSEARCH_SELECT_STUDY",

					'selectors' => array(
										'onchange' => $event
									)
					));
				echo "</div>";
				echo "</div>";



				break;


		}

		jexit();
	}
The administrator has disabled public write access.

Re: Set ordering of combo-box items 07 Mar 2013 17:27 #6924

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi & welcome!

I believe that the values retrieved will sorted by the default field of the table from which they are being pulled. Check in the builder by navigating to the table in question and set the default field to your "title" field by clicking the star next to it.

Hopefully that will sort it out for you.

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
Time to create page: 0.099 seconds

Get Started