Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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();
	}

Please Log in or Create an account to join the conversation.

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

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
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!!!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.124 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started