Yii Framework Forum: Export Data To .xls File With Selgridview (Checkbox Selected) And Phpexcel Extension - Yii Framework Forum

Jump to content

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

Export Data To .xls File With Selgridview (Checkbox Selected) And Phpexcel Extension Rate Topic: -----

#1 User is offline   zorbathegreek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 15-March 13

Posted 18 March 2013 - 12:13 PM

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 ...
0

#2 User is offline   zorbathegreek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 15-March 13

Posted 03 April 2013 - 11:34 AM

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!
0

#3 User is offline   m@ster 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 02-April 12

Posted 09 May 2013 - 08:54 AM

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
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