jquerycascadeselect JQuery Cascade Select

  1. Documentation
  2. Change Log

This extension is made to build a chained select lists Tested only under the site downloaded from the forum "An idea for Role Based Access Control"

Resources

Documentation

Requirements
  • Yii 1.0.3 or above
  • JQuery
Installation
  • Extract the release file under protected/extensions
Usage

See the following code example: On top of the view:

$jqcs = $this->createWidget('application.extensions.JQueryCascadeSelect.JQueryCascadeSelect');

In the form initially you have to add a normal DropDown To add a chained DropDown you have to do one of the next lines, depinding on your needs (first params like in classic dropdown):

echo $jqcs->makeDropDown('id', '', $data, array('size'=>5),'getdata','chainedid');
echo $jqcs->makeActiveDropDown($model,'id', $data, array('size'=>5),'getdata','chainedid');

A function which serves the info needed:

public function actionGetdata()
{
 $ret = "";
 if(Yii::app()->request->isAjaxRequest)
 if($_GET['val'] != 'null'){
  $cm = Chainedmodel::model()->findbyPk($_GET['val']);
  if($firm){
   $neededmodels = $cm->getRelated('neededmodel');
   $i = 0;
   foreach($neededmodels as $row){
    if($i != 0) $ret .= ","; else $i++;
    $ret .= "{'Value':'".$row["id"]."','Text':'".$row["name"]."'}";
   }
  }
 }
 echo "[".$ret."]";
}

Change Log

May 22, 2009
  • Initial release.
2 0
4 followers
927 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Tags:
Developed by: Paul Apostol
Created on: May 22, 2009
Last updated: 14 years ago

Downloads

show all