Yii Framework Forum: [EXTENSION] EMultiSelect - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] EMultiSelect Rate Topic: ****- 1 Votes

#1 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 12 May 2011 - 11:19 AM

Extension: http://www.yiiframew...n/emultiselect/
1

#2 User is offline   Kamarul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 05-April 11
  • Location:Malaysia

Posted 16 May 2011 - 01:09 AM

Nice extension but with a few bugs.. ;)

When add to form..
$this->widget('application.widget.emultiselect.EMultiSelect',  
  array('sortable' => true, 'searchable' => true) 
);  


Change to..
$this->widget('application.extensions.emultiselect.EMultiSelect', 		
  array('sortable' => true, 'searchable' => true)   	
); 


EmultiSelect.php - Line #60
$basePath=Yii::getPathOfAlias('application.widget.emultiselect.assets');  


Change to...
$basePath=Yii::getPathOfAlias('application.extensions.emultiselect.assets'); 

.. or ..
$resources = dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'; 
$basePath  = Yii::app()->assetManager->publish($resources);  

The only valid measurement of code quality: WTF / Minute
0

#3 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 16 May 2011 - 08:23 PM

Sorry, I think I developed it in the widget directory so I just updated install to have it placed in widget not extension. (That way it matches zii.widget.___ for the other for widgets.)
0

#4 User is offline   spkuk 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-May 11

Posted 18 May 2011 - 08:43 AM

I have got this extension running. It looks great - thank you!

I am not sure how to go about getting the records to save. This is used to select tracks on a playlist.

My _form has the following code.

$tracks = Track::model()->findAll();
$data = array();
foreach ($tracks as $track)
$data[$track->idtrack] = $track->name . ' '. $track->idtrack;

echo $form->dropDownList(
$model,
'tracks',
$data,
array('multiple'=>'multiple',
'key'=>'tracks', 'class'=>'multiselect'));

$data contains a list of all idversions, displaying the name and idversion.

Should this be saved into a char() column? Should I save the list of idtracks on the tracks column? I am getting an error when I try and do this. The error is "Array to string conversion".

Any suggestions anyone? Clearly I am fairly new to this!

Thanks
0

#5 User is offline   spkuk 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-May 11

Posted 18 May 2011 - 10:04 AM

I have sorted this. Thanks anyway.

Solution found.
0

#6 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 26 May 2011 - 10:08 PM

I recommend using foreign keys in a separate table to save things like this.
In which case, you would probably be using a manymany relation so this behavior can also help with saving: http://www.yiiframew...ons-ar-behavior
Then, Yii can autoselect things for you. (Use the key option for the dropdown.)

Eg In _form.php
<?php
    	$post=Trainingo::model()->findAll();
    	$trainings = CHtml::listData($post, 'training_id', 'name'); // Get the list of options
    	echo $form->dropDownList(
        	$model,
        	'trainingosCall',
        	$trainings,
        	array(
            	'multiple'=>'multiple',
            	'key'=>'training_id', // The id from the table
            	'class'=>'multiselect',
        	)
    	);
?>

In model relations function:
'trainingosCall' => array(
  	self::MANY_MANY,
  	'Trainingo',
  	'call_trainingo(call_id, trainingo_id)'
),


Note: I have a table call_trainingo with 2 columns call_id and trainingo_id to relate them.

Then to save (using the behavior above also):
        	$model->attributes=$_POST['Call'];
        	if (!is_array(@$_POST['Call']['trainingosCall'])) {
            	$_POST['Call']['trainingosCall2'] = array();
        	}
        	$model->setRelationRecords(
            	'trainingosCall', $_POST['Call']['trainingosCall']
        	);
        	$model->save();

0

#7 User is offline   waitforit 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 413
  • Joined: 09-February 11

Posted 25 June 2011 - 10:31 PM

Thanks for making this extension - using it in one of my projects and its AWESOME.

One enhancement I was thinking about is a shortcut to creating additional items in the 'other' table of relations.

For example, lets use a MANY_MANY relationship of Posts and Categories.

When using eMultiSelect I can display a post with related categories and assign them dynamically on the fly. It would be nice to be able to add additional categories on the fly while doing the assignment in the post model.

I also have a 'categories' management in my app but trying to think of a good way to do this.. part of this extension or just a secondary form on the same page?
0

#8 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 26 June 2011 - 08:48 PM

View Postdniznick, on 25 June 2011 - 10:31 PM, said:

Thanks for making this extension - using it in one of my projects and its AWESOME.

One enhancement I was thinking about is a shortcut to creating additional items in the 'other' table of relations.

For example, lets use a MANY_MANY relationship of Posts and Categories.

When using eMultiSelect I can display a post with related categories and assign them dynamically on the fly. It would be nice to be able to add additional categories on the fly while doing the assignment in the post model.

I also have a 'categories' management in my app but trying to think of a good way to do this.. part of this extension or just a secondary form on the same page?

Thanks.

Let me make sure I understand first, you are basically wanting a way to add additional options (in your case categories) via AJAX (which would create the new option in the database and update the list)?

I think you would probably have to build that in yourself, though you might find an extension to make it work. You would need to have an AJAX handler in the controller and a field that could post the new category, then it would need to add the option to your dropdown and possibly refresh the multiselect thing to get it to update.

Alternatively, it might be easier to just use JS on the client side and then deal with the added options on save rather than adding them via AJAX. Then of course you would be validating later on the new options so you might run into some validation issues on the new category that you would have to handle.

I hope that make some since and helps a little. I will be happy to guide you as much as possible as you go, but I don't think I will be able to code it.

(As a side note, minus the refreshing of the jquery multiselect, this would be exactly the same as if you weren't using EMultiSelect because all I've done is change a JQuery addon to where it plays nicely with Yii Extensions.)
0

#9 User is offline   zuups 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-June 11
  • Location:Estonia

Posted 30 June 2011 - 05:22 AM

Thanks for the extension!

It worked for me with MANY_MANY mode, when

- Set the foreign keys in the intermediate table. That was possible when
-- All related tables' ENGINE=InnoDB
-- There are only valid values in that table (or empty table)

Although obvious for most people, maybe it helps newcomers (like me) :)
0

#10 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 28 July 2011 - 12:52 AM

hello...
I want to update existing data with ajax.
data is changed, but not refreshed ..
I think want to put a trigger to click the remove-all so the results can be refreshed

is it possible?<br>and it is possible to add onchange???<br>

This post has been edited by Mr D: 29 July 2011 - 01:08 AM

Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#11 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 29 July 2011 - 07:01 AM

I'm not sure I completely understand, but I'm sure it is possible if you read the manual for the underlying jQuery extension http://www.quasipart...at/multiselect/
You may have to modify my code somewhat to allow you to set

Their also appear to be a next version that supports AJAX

Quote

jQuery UI Multiselect Next (now runs on jQuery UI 1.8 )
This is a more advanced but not well tested extended version of the jQuery UI Multiselect widget.
It just got updated to work along with jQuery 1.4.2 and jQuery UI 1.8.

I’ve installed a demo page at http://quasipartikel...ltiselect_next/

-
For the original version done by Yanick (which is based on jQuery 1.3 and jQuery UI 1.7) please visit his demo page:

http://yanickrochon....om/multiselect/

If you have suggestions or did some nice modifications just let us know.
We’d be happy to review them, and perhaps include them.


My addon essentially just wraps the jQuery plugin so feel free to see how that is done to wrap one of the other verisons or to use features out of this version.
0

#12 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 04 September 2011 - 09:33 PM

hello .. sorry to bother .. I use your extension and datepicker in a form .. but extension datepicker does not work properly datepicker enxtension ::http://www.yiiframew.../extension/jui/ Because of what Things like this happen?


and 1 more

when I click the plus sign in a hurry, the value in Colom selected become duplicate

Attached File  emulti.JPG (15.33K)
Number of downloads: 71

I run it in mozilla6.0
duplicate
Attached File  emulti_doble.JPG (14.74K)
Number of downloads: 72
Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#13 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 05 September 2011 - 07:51 PM

View PostMr D, on 04 September 2011 - 09:33 PM, said:

hello .. sorry to bother .. I use your extension and datepicker in a form .. but extension datepicker does not work properly datepicker enxtension ::http://www.yiiframew.../extension/jui/ Because of what Things like this happen?


and 1 more

when I click the plus sign in a hurry, the value in Colom selected become duplicate

Attachment emulti.JPG

I run it in mozilla6.0
duplicate
Attachment emulti_doble.JPG

Yii has datepicker built in now so you should not need to use that extension.
http://www.yiiframew.../CJuiDatePicker

As far as the doubling goes. I cannot reproduce it on my system, but that is an error in the js of the extension so you can report that to the js extension creator here: http://www.quasipart...at/multiselect/
If he makes changes, please update me so I can correct the copy of his js in my code.
0

#14 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 12 September 2011 - 03:04 AM

hi loren...
I think jquery multiselect been updated

https://github.com/c...sch/multiselect ;D ;D ;D
Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#15 User is offline   Loren 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 29-December 10
  • Location:SC, USA

Posted 13 September 2011 - 02:25 PM

ok, I just updated the extension.
0

#16 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 25 March 2012 - 05:31 AM

Thank you so much for the great example you made here in this thread,
now I have a height issue, the multiselect does not want to obey me :P I changed to:

/* multiselect styles */
	.multiselect {
		width: 660px;
		height: 400px;
	}

The width changes, but not the height. I've tried cleaning the root assets folder(where yii publishes everything).
Didn't work (was not required for the width to change anyway..)
So I inspected it with firebug and I've found the problem,
<ul class="selected connected-list ui-sortable" style="height:32px">
<ul class="available connected-list" style="height: 32px;">


Cant find though where these attributes come from, any idea?
0

#17 User is offline   waitforit 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 413
  • Joined: 09-February 11

Posted 26 March 2012 - 01:34 PM

Open up the javascript file in the extensions folder.
0

#18 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 27 March 2012 - 11:00 AM

View Postwaitforit, on 26 March 2012 - 01:34 PM, said:

Open up the javascript file in the extensions folder.

I've ofcoursed checked thrue that and the .css file already...
0

#19 User is offline   an0nz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 28-March 12

Posted 28 March 2012 - 01:31 AM

This looks great, I will have to give it a try. Hopefully everyone else here has solved the bugs for me :)
0

#20 User is offline   Astart 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-February 12
  • Location:Dublin

Posted 28 March 2012 - 09:17 AM

Hi, I have a question. I have three tables: User(userID, etc), Owner(ownerID, etc) and UserToOwner(userID, ownerID). Relation between User and Owner is MANY_MANY.
I am displaying all Owners in the table so the user can populate userToOwner, but I'd also like to display all owners that are related to user(userToOwner) as selected. Is it possible?

Got it sorted, nevermind.

If you ever get this problem, just create an array of values to be selected, ie:

foreach($model->owners as $ownerID)
{
$array[$ownerID->ownerID] = array("selected"=>true);
}

and pass $array to options: 'options'=>$array
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users