Yii Framework Forum: Xmultiselects Widget -- Is There A Way To Filter The Contents? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Xmultiselects Widget -- Is There A Way To Filter The Contents? Rate Topic: -----

#1 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 22-September 12

Posted 07 March 2013 - 12:20 PM

I am using the XMultiSelects widget. I have a list of sites for the user to review and approve.

I would like to put a filter on the page above the list to allow the user to filter the list by category.
I can add a dropdownlist object, but not sure how to trigger the update.

My _searchCat.php file
<div class="wide form">

<?php $form = $this->beginWidget('CActiveForm', array(
	'action' => Yii::app()->createUrl($this->route),
	'method' => 'get',
)); ?>

	<div class="row">
		<?php echo $form->label($model, 'campaign_id'); ?>
		<?php echo $form->dropDownList($model, 'campaign_id', CHtml::listData(Campaign::model()->findAll('partner_id ='.$partner_id),'id', 'title'), array( 'prompt'=>'Select Campaign')); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'category_id'); ?>
		<?php echo $form->dropDownList($model, 'category_id', CHtml::listData(ContentCategory::model()->findAll(),'id', 'category'), array('multiple'=>'multiple', 'prompt'=>'Pick Any', 'unselectValue'=>NULL )); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton(Yii::t('app', 'Search')); ?>
	</div>

	
<?php $this->endWidget(); ?>

</div><!-- search-form -->


My approve.php file


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('ApproveSites', {
data: $(this).serialize()
});
return false;
});
");
?>

<?php echo CHtml::link(Yii::t('app', 'Category Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
    <?php $this->renderPartial('_searchCats',array(
    'model'=>PartnerSite::model()->find($model->id), 'partner_id'=>$model->id,
)); ?>
</div><!-- search-form -->

<div class="form">
<br />

<?php echo $form = CHtml::beginForm($this->createUrl('ApproveSites')); ?>

<?php if ($mode == 'Blacklist') 	

$this->widget('ext.widgets.multiselects.XMultiSelects',array(
        'leftTitle'=>$lefthead,
        'leftName'=>'PartnerSite[needreview][]',
        'leftList'=>PartnerSite::model()->findSites($model->id,'NeedReview'),
        'rightTitle'=>$righthead,
        'rightName'=>'PartnerSite[approved][]',
        'rightList'=>PartnerSite::model()->findSites($model->id,'Approved'),
        'size'=>20,
        'width'=>'300px',
        ));
....



My model had a method defined
public function findSites($partner_id, $approve, $cat)
	{		
		$criteria=array(
			'select'=>' partner_id, website_id, approve ',					
			'condition'=>'partner_id='.$partner_id.' and approve ='."'$approve'",
			'order'=>'site_url',
		);			
		$partnerSites = PartnerSite::model()->with('website')->findAll($criteria);
		return CHtml::listData($partnerSites,'id','website.site_url');		
	}

How do I get this to reload the list in the widgets?

Thanks for any help or ideas!
0

#2 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 22-September 12

Posted 20 March 2013 - 06:22 PM

View PostAustinGeek, on 07 March 2013 - 12:20 PM, said:

I am using the XMultiSelects widget. I have a list of sites for the user to review and approve.

I would like to put a filter on the page above the list to allow the user to filter the list by category.
I can add a dropdownlist object, but not sure how to trigger the update.

My _searchCat.php file
<div class="wide form">

<?php $form = $this->beginWidget('CActiveForm', array(
	'action' => Yii::app()->createUrl($this->route),
	'method' => 'get',
)); ?>

	<div class="row">
		<?php echo $form->label($model, 'campaign_id'); ?>
		<?php echo $form->dropDownList($model, 'campaign_id', CHtml::listData(Campaign::model()->findAll('partner_id ='.$partner_id),'id', 'title'), array( 'prompt'=>'Select Campaign')); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'category_id'); ?>
		<?php echo $form->dropDownList($model, 'category_id', CHtml::listData(ContentCategory::model()->findAll(),'id', 'category'), array('multiple'=>'multiple', 'prompt'=>'Pick Any', 'unselectValue'=>NULL )); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton(Yii::t('app', 'Search')); ?>
	</div>

	
<?php $this->endWidget(); ?>

</div><!-- search-form -->


My approve.php file


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('ApproveSites', {
data: $(this).serialize()
});
return false;
});
");
?>

<?php echo CHtml::link(Yii::t('app', 'Category Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
    <?php $this->renderPartial('_searchCats',array(
    'model'=>PartnerSite::model()->find($model->id), 'partner_id'=>$model->id,
)); ?>
</div><!-- search-form -->

<div class="form">
<br />

<?php echo $form = CHtml::beginForm($this->createUrl('ApproveSites')); ?>

<?php if ($mode == 'Blacklist') 	

$this->widget('ext.widgets.multiselects.XMultiSelects',array(
        'leftTitle'=>$lefthead,
        'leftName'=>'PartnerSite[needreview][]',
        'leftList'=>PartnerSite::model()->findSites($model->id,'NeedReview'),
        'rightTitle'=>$righthead,
        'rightName'=>'PartnerSite[approved][]',
        'rightList'=>PartnerSite::model()->findSites($model->id,'Approved'),
        'size'=>20,
        'width'=>'300px',
        ));
....



My model had a method defined
public function findSites($partner_id, $approve, $cat)
	{		
		$criteria=array(
			'select'=>' partner_id, website_id, approve ',					
			'condition'=>'partner_id='.$partner_id.' and approve ='."'$approve'",
			'order'=>'site_url',
		);			
		$partnerSites = PartnerSite::model()->with('website')->findAll($criteria);
		return CHtml::listData($partnerSites,'id','website.site_url');		
	}

How do I get this to reload the list in the widgets?

Thanks for any help or ideas!


I guess nobody has used this extension.
0

#3 User is offline   anu1992 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 29-October 12

Posted 15 May 2013 - 07:41 AM

View PostAustinGeek, on 07 March 2013 - 12:20 PM, said:

I am using the XMultiSelects widget. I have a list of sites for the user to review and approve.

I would like to put a filter on the page above the list to allow the user to filter the list by category.
I can add a dropdownlist object, but not sure how to trigger the update.

My _searchCat.php file
<div class="wide form">

<?php $form = $this->beginWidget('CActiveForm', array(
	'action' => Yii::app()->createUrl($this->route),
	'method' => 'get',
)); ?>

	<div class="row">
		<?php echo $form->label($model, 'campaign_id'); ?>
		<?php echo $form->dropDownList($model, 'campaign_id', CHtml::listData(Campaign::model()->findAll('partner_id ='.$partner_id),'id', 'title'), array( 'prompt'=>'Select Campaign')); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'category_id'); ?>
		<?php echo $form->dropDownList($model, 'category_id', CHtml::listData(ContentCategory::model()->findAll(),'id', 'category'), array('multiple'=>'multiple', 'prompt'=>'Pick Any', 'unselectValue'=>NULL )); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton(Yii::t('app', 'Search')); ?>
	</div>

	
<?php $this->endWidget(); ?>

</div><!-- search-form -->


My approve.php file


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('ApproveSites', {
data: $(this).serialize()
});
return false;
});
");
?>

<?php echo CHtml::link(Yii::t('app', 'Category Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
    <?php $this->renderPartial('_searchCats',array(
    'model'=>PartnerSite::model()->find($model->id), 'partner_id'=>$model->id,
)); ?>
</div><!-- search-form -->

<div class="form">
<br />

<?php echo $form = CHtml::beginForm($this->createUrl('ApproveSites')); ?>

<?php if ($mode == 'Blacklist') 	

$this->widget('ext.widgets.multiselects.XMultiSelects',array(
        'leftTitle'=>$lefthead,
        'leftName'=>'PartnerSite[needreview][]',
        'leftList'=>PartnerSite::model()->findSites($model->id,'NeedReview'),
        'rightTitle'=>$righthead,
        'rightName'=>'PartnerSite[approved][]',
        'rightList'=>PartnerSite::model()->findSites($model->id,'Approved'),
        'size'=>20,
        'width'=>'300px',
        ));
....



My model had a method defined
public function findSites($partner_id, $approve, $cat)
	{		
		$criteria=array(
			'select'=>' partner_id, website_id, approve ',					
			'condition'=>'partner_id='.$partner_id.' and approve ='."'$approve'",
			'order'=>'site_url',
		);			
		$partnerSites = PartnerSite::model()->with('website')->findAll($criteria);
		return CHtml::listData($partnerSites,'id','website.site_url');		
	}

How do I get this to reload the list in the widgets?

Thanks for any help or ideas!


Can you please add the code how database insertion of the values is done using this multiselect ??
0

Share this topic:


Page 1 of 1
  • 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