[EXTENSION] asmselectex (jQuery based)
#1
Posted 10 January 2009 - 02:04 AM
Demo: http://ironic.tnzr.n...mselectex/demo/
Screenshots: http://ironic.tnzr.n...ex/screenshots/
The orginal:
jQuery asmselect plugin: http://code.google.c...uery-asmselect/
Please post bug reports here.
#3
Posted 10 January 2009 - 01:56 PM
#4
Posted 11 January 2009 - 04:05 AM
Quote
Thank you and thank you for this great framework!
Quote
You´re welcome.
Looking forward to some feedback.

#6
Posted 14 January 2009 - 11:44 AM
- Is it possible to use setters and getters for the params? that way you don't need to place the checks inside the [tt]run[/tt] method. If you want to do it that way, It's simple, you just make your properties [tt]private[/tt] and write [tt]public function setProperty[/tt] and [tt]public function getProperty[/tt] methods
- Why do you use [tt]sprintf[/tt]? is it a question of style or for anything functional? (I prefer heredoc, but that's a matter of style only, because IMHO is better for readability)
- I also think that using [tt]CHtml[/tt] static methods is better than using HTML directly, at least more elegant (whatever that means
)
- It'd be cool to make it a [tt]CInputWidget[/tt], so it could be an active or "normal" widget, using [tt]CHtml::activeDropDownList[/tt] or [tt]CHtml::dropDownList[/tt] depending on [tt]$this->hasModel[/tt]
- Also, it would be neat to set the labels directly as widgets parameters (I know, they can be set using [tt]scriptOptions[/tt] directly anyway
)
#7
Posted 14 January 2009 - 10:00 PM
Usage example:
<?php
$arrOptions = array(
'value1'=>'The Option text.',
'group1'=>array(
'value2'=>'option 2',
'value3'=>'option 3'
),
'value4'=>'option 4',
'value5'=>'option 5'
);
$this->widget('application.extensions.asmselectex.EAsmSelectEx',
array(
'name' => 'asmSelect',
'value' => $arrOptions,
'select' => array('value1', 'value3'),
'htmlOptions' => array('size'=>4),
'options' => array('addItemTarget'=>'bottom','animate'=>true,'highlight'=>true,'sortable'=>true)
)
);
?>
Attached File(s)
-
asmselectex-metayii-1.2.zip (25.74K)
Number of downloads: 15
#8
Posted 16 January 2009 - 03:50 AM
first of all, thanks for reviewing the code and your feedback.
Quote
- Is it possible to use setters and getters for the params? that way you don't need to place the checks inside the [tt]run[/tt] method. If you want to do it that way, It's simple, you just make your properties [tt]private[/tt] and write [tt]public function setProperty[/tt] and [tt]public function getProperty[/tt] methods
All Properties, are now declared as private and have their corresponding getter and setter functions.
Note the "special" getter and setter for a single scriptOption (see end of the post).
Quote
- Why do you use [tt]sprintf[/tt]? is it a question of style or for anything functional? (I prefer heredoc, but that's a matter of style only, because IMHO is better for readability)
- I also think that using [tt]CHtml[/tt] static methods is better than using HTML directly, at least more elegant (whatever that means
)
Only 1 sprintf left.

I know sprintf is a bit deprecated, but I hate <<<< operators.

The new renderWidget function is now completly based on CHtml static methods,
and you are right about the fact, that it looks way more elegant.
Quote
- It'd be cool to make it a [tt]CInputWidget[/tt], so it could be an active or "normal" widget, using [tt]CHtml::activeDropDownList[/tt] or [tt]CHtml::dropDownList[/tt] depending on [tt]$this->hasModel[/tt]
Didnt had a look at CHtml::activeDropDownList, neither at CHtml::dropDownList.
So I really dont know if they support optgroups or not.
But it would be cool to support $this->hasModel functionallity,
even if I would realy need some help on the implementation.
Quote
- Also, it would be neat to set the labels directly as widgets parameters (I know, they can be set using [tt]scriptOptions[/tt] directly anyway
)
$myAsmSelect->setScriptOption('removeLabel', 'revoke');
$myAsmSelect->setScriptOption('highlightAddedLabel', 'assigned: ');
$myAsmSelect->setScriptOption('highlightRemovedLabel', 'revoked: ');
$myAsmSelect->setScriptOption('sortable', true);

Regarding, your second post, I totally missed your attachment :blonk:, but thanks again for your help.

Ahhh and 'htmlOptions' => array('size'=>4) wont really work,
because the asmselect script ignores/overwrites the html size attribute.
Here an article about "Finding a better solution for multiple selection":
http://www.ryancrame...elect_multiple/
written by the coder of the original asmselect-jquery plugin, it may
explain why there is no size-attribute anymore.
with kind regards
ironic
#9
Posted 16 January 2009 - 03:54 AM
Download: http://www.yiiframew...ectex/#download
Documentation: http://www.yiiframew...smselectex/#doc
Note: See the documentation for all changes.
Important:
- note the camel-case for the classname! (now: EAsmSelectEx)
- $values property is now named $data
#10
Posted 16 January 2009 - 09:19 AM
yes, the [tt]CHtml::activeDropDownList[/tt] and [tt]CHtml::dropDownList[/tt] methods support optgroups. The advantages of using them are that you can use the form as an AR, it's shorter and, well, they'll already there.
This is the link to download the code I uploaded, BTW:
http://www.yiiframew...509.0;attach=92
(20090119: fixed some bug)
Greetz
#11
Posted 04 February 2009 - 02:32 AM
Class Changes
- implements the suggestions of MetaYii to extend the class from CInputWidget
Script Changes
- updated the jquery.ui.js to version 1.5.3 to keep compatibility with jQuery 1.3
- updated the jquery.tinysort.min.js to version 1.0.2
Download: http://www.yiiframew...ectex/#download
Examples: http://www.yiiframew...smselectex/#doc
Class Documentation: http://ironic.tnzr.nl/asmselectex/
Notes on updating!
See the updated Examples and the Class Documentation for all changes.
#12
Posted 17 April 2009 - 05:25 AM
#13
Posted 17 April 2009 - 04:26 PM
Why it should not be possible?
You can use ironics AsmSelectEx widget and add the needed JavaScript code.
Something like:
inside your view.
Or did i get you wrong?
Greets yoshi
#14
Posted 17 April 2009 - 09:34 PM

Another questions regarding this widget. Is it possible to create columns like that:
[col1][col2][col3][col4]
[value][value1][value2][remove]
[value][value1][value2][remove]
[value][value1][value2][remove]
[value][value1][value2][remove]
and to easily remove "remove button"?
What about replacing added values: when i choose another option from dropdown list, chosen value will replace the one displayed?
I'm asking this question because my javascript knowledge sucks, that why I've previously used Prado framework and now I want to switch to yii and I have this probles.
#15
Posted 06 May 2009 - 03:47 PM
I had an issue and was hoping I could get some help.
Using your extension with the model, my $_POST wasn't being populated as expected. In my view:
$this->widget('application.extensions.asmselectex.EAsmSelectEx',
array(
'model' => $siteForm,
'attribute' => 'problemViews',
'data' => CHtml::listData($problemViews,'id','description'),
'htmlOptions' => array('title'=>"Available Problem Views"),
'scriptOptions' => array('addItemTarget'=>'bottom',
'highlight'=>true,
'sortable'=>false)
)
);
When submitting the form, my $_POST had something like:
Array
(
[SiteForm] => Array
(
[username] => test
...
[0] => Array(
[problemViews] => Array(
[0] => 5
)
)
[1] => Array(
[problemViews] => Array(
[0] => 11
)
)
)
instead of the desired:
Array
(
[SiteForm] => Array
(
[username] => test
...
[problemViews] => Array
(
[0] => 5
[1] => 11
)
)
)
Looking through the generated HTML, the name for the select element was 'SiteForm[][problemViews][]'. My problem was the first '[]' which was being added on line 200 of EAsmSelectEX.php
I changed the line from:
? CHtml::activeDropDownList($this->model, $this->attribute.'[]', $this->_data, $this->htmlOptions)
to
? CHtml::activeDropDownList($this->model, $this->attribute, $this->_data, $this->htmlOptions)
which gave me what I wanted. This is the only place I'll be using the extension so I haven't looked into how that change would effect other options. Any ideas on what I was doing wrong? Or was that a necessary change?
#16
Posted 31 May 2009 - 09:16 PM
? CHtml::activeDropDownList($this->model, $this->attribute.'[]', $this->_data, $this->htmlOptions)
It works perfect now.
Greg
#17
Posted 22 April 2010 - 02:13 AM
$users = t_jabatan::model()->findAll(array('select'=>array('ID_Jabatan', 'Nama_Jabatan', 'ID_Organisasi'))); foreach($users as $user){ $organisasi = CHtml::listData(t_organisasi::model()->findAll(array('condition'=>'ID_Organisasi=\''.$user->ID_Organisasi.'\'')), 'ID_Organisasi', 'Nama'); $UserList[$organisasi[$user->ID_Organisasi]][$user->ID_Jabatan]=$user->Nama_Jabatan; } //$arrSelected = array(8, 12); try { $this->widget('application.extensions.asmselectex.EAsmSelectEx', array( 'model' => t_jabatan::model(), 'attribute' => "ID_Jabatan", 'data' => $UserList, 'selected' => array(12,2), 'htmlOptions' => array('title'=>"Select a Item."), 'scriptOptions' => array('addItemTarget'=>'bottom', 'animate'=>true, 'highlight'=>true, 'sortable'=>true), ) ); } catch (Exception $e) { echo 'Caught Exception: ', $e->getMessage(), "<br />\n"; }
HTML Code
<select title="Select a Item." id="t_jabatan_ID_Jabatan" multiple="multiple" name="t_jabatan[ID_Jabatan][]"> <optgroup label="IT Solution"> <option value="12">Supervisor</option> </optgroup> <optgroup label="Computer Supply"> <option value="7">Manager</option> <option value="8">Staff</option> </optgroup> <optgroup label="Open Source"> <option value="1">Sekretaris</option> <option value="2">Administrator</option> </optgroup> </select>
thank for the code.. this is very good one.
#18
Posted 22 April 2010 - 09:52 PM
Error: $(input).zIndex is not a function Source File: http://testdrive.localhost/internal/assets/20208866/js/jquery-ui.min.js Line: 42
any one know?..
This is my CJuiDatePicker code :
$this->widget('zii.widgets.jui.CJuiDatePicker', array( 'name'=>'t_karyawan[Tanggal_Lahir]', 'model'=>$model, 'attribute'=>'Tanggal_Lahir', // additional javascript options for the date picker plugin 'options'=>array( 'showAnim'=>'show', 'showOn'=>'button', 'buttonImage'=>'images/calendar.png', 'buttonImageOnly'=> true, 'dateFormat'=>'dd/mm/yy', 'yearRange'=>'1950:1995', 'changeMonth'=>true, 'changeYear'=>true, ),
thx.
#19
Posted 23 April 2010 - 01:39 AM
? CHtml::activeDropDownList($this->model, $this->attribute.'[]', $this->_data, $this->htmlOptions)
if you remove '[]', you will only get 1 data, canot get select multiple. this just compatible yii version.
just print_r() in your model.
print_r($_POST['country']); // work
print_r($this->country); // not work, no value.
ooo....
#20
Posted 04 October 2010 - 07:53 PM
In case of validation error in others form elements how do I keep the values selected already in EAsmSelectEx before the post action?
What happens now is that the values selected are reset in case of validation error of some form element.
Thanks in advance