Export Data To .xls File With Selgridview (Checkbox Selected) And Phpexcel Extension

Hi all,

I’am a newbie in Yii and have the following in my view (also see title):




<script type="javascript">var selected = $("#my-grid").selGridView("getAllSelection");</script>


<?php 

    $this->widget('ext.selgridview.SelGridView', array(

        'id'            =>'my-grid',

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

        'filter'        =>$model,

        'selectableRows'=>2, // for CCheckBoxColumn

        'ajaxUpdate'    =>TRUE,

        'columns'       =>array(

                           // CCheckBoxColumn array

                           array(

                                  'class'      =>'CCheckBoxColumn',

                                  'htmlOptions => array(

                                                        'style'     =>'text-align:center',

                                                       ),

                                   'id'        =>'selectedIds', // the columnID for getChecked

                                   'footer'    =>'checked',

                                   'checked'   =>'js:{checked:$("selected")}',

                                 ),

                            

                           'address_current',

                           'other_field',

                             array(

                        	   'class' =>'CButtonColumn',

                                  ),

        	),

        )); ?>


    <?php

            

        echo CHtml::ajaxButton(

                     'Export Selected',

                     Yii::app()->createUrl( 'myController/myexportaction' ),

                     array( //ajax options

                           'type'=>'POST',

                           'data'=>'js:{checked:$("#my-grid").selGridView("getAllSelection"), selectedIds:$("#my-grid").selGridView("getAllSelection").toString()}',

                            //'success'=>"alert('Hello')",  // works!

                           ),

                     array( //htmlOptions

                            'href'  => Yii::app()->createUrl( 'myController/myexportaction' ),

                            'class' => $class,

                           )

                   );

    ?>



When I click on the ajax-Button to export the selected (checked) records, there is a response in Firebug: I can see the correct Ids of the checked records, but no .xls file is produced nor an error is thrown in firebug. I have also an "exportAll" method with the same phpExcel-code to write the .xls file, which works without any problems. I am little bit lost in what to do next, is somebody out there who can help?

Thanks in advance!

P.S. By the way, great framework, please keep up the good work, developers! Much appreciated. Sorry for my bad english…

Edit: Dear moderators, can you please move this post to forum "extensions", thank you and sorry for wrong-posting …

Hi all,

I tried several things with no luck, probably an ajax thing… is anybody out there, who can push me in the right direction, please? Thanks in advance!

I have the same problem

the solution is to Direct the output to a new browser window if success.

but i don’t know to do