Yii Framework Forum

CGridView selectable keeping selection


(Hmsegura) #1

Hi

How do I maintain the selection when I navigate between pages?

property ‘selectableRows’=>2,





$this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'expedientes-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

        'selectableRows'=>2,//select more than one

	'columns'=>array(

        ......



thanks


(Hmsegura) #2

with this http://www.yiiframework.com/extension/selgridview/

and a little change work fine


(Noginsk) #3

Hi Horacio,

Thank you, fixed in last version.

Now user’s CheckBoxColumn gets “checked” value correctly.


(Hmsegura) #4

I have introduced a small change, again

because it was not good with the previous

declare a global variable in the client widget

and set it in the widget





<script type="text/javascript">

	var selectionGlobal='';

   function show(){

 		alert ("selection="+

    	seleccionGlobal+","+  //stored selection in params

    	$.fn.yiiGridView.getSelection('xxxxx-grid')); //not yet stored in params

}

</script>

...

$this->widget('application.extensions.SelGridView', array(

 ...




the change in SelGridView at the end of protected function applyBeforeAjaxUpdate()




  ..

   function applyBeforeAjaxUpdate()

   ...

   seleccionGlobal=params[selVar]

   ...



I need help to make this more elegant

for example, $.fn.yiiGridView.getWholeSelection() method

thanks


(Jcsmesquita) #5

Thanks for this code!


(Noginsk) #6

Hi all

I’ve updated SelGridView

Now you can use this method to get all selected keys on all pages:




var selected = $("#mygrid").selGridView("getAllSelection");




(Tiago) #7

Hi,

I’m new to yii framework and was trying to use Selgridview, to have a table with some contents that later on i will be retrieving them from a noSQL engine. My problem is, i seem not to be able to show the grid in my index page. I tried to use the example code but always keep getting this :

Fatal error: Call to a member function getId() on a non-object in /var/www/front_end/protected/extensions/selgridview/SelGridView.php on line 33

i dont know if its something on my side or if its in SelGridView code.

thanks in advance.

Tiago.


(Ljowen985) #8

Hi guys,

I wonder why my pager url increasing longer and longer every time i click on the cgridview pager list??

http://localhost/.../mygrid/user_sel[2]/2/user_sel[3]/2/user_sel[4]/2

I follow page example on selgridview and demo

thanks man,


(Vitalyhome) #9

//thanks to Horacio Segura http://www.yiiframework.com/extension/selgridview/#c7346 

        foreach($this->columns as $col) {

            if($col instanceof CCheckBoxColumn) {

                $col->checked = $checkedExpression; 

                $col->init();

                return;

            }

        }

SelGridView.php Line 66.

I just want to notice, that this patch is not a good idea.

When user already have CCheckBox column AND checked property defined - this code overrides user-defined checked property and checkboxes never will be checked. I think there is some other fix needed.


(Contactvinodc) #10

Hi,

I addeed selgridview and no i can select the all row or the rows i needed .

but i dont know how to pass these array of values to the controller.

All i needed is to pass the values to the controller using a button.

i only found how to add selgridview.

please help me i’m new to yii

thanks in advance


(C Pandit) #11

i am new in framework pls help me any one

i can use this selgridview but don’t show the checkbook , what can i do ? what to add in js file


(Pazipl) #12

If you want to add selection to selgirdview on pages, you can fill $_GET array in controller, for example:


$_GET['Modelname_sel'] = array(1,2,3,4,5,6,7,8,9,10,21,22,23,24)

it works without extending js file.