Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8716297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:02:54+00:00 2026-06-13T06:02:54+00:00

I wrote a Class MyGridView extends from the CGridView. MyGridView will automaticlly generate two

  • 0

I wrote a Class MyGridView extends from the CGridView.
MyGridView will automaticlly generate two buttons in the header,
one is a pdf icon, another is a excel icon. but how can I bind event to this two icon?
so that I can use my code to generate PDF or EXCEL for this CGridView based on the dataprovider and columns.

the PDF export code and the EXCEL export code are all ready, I just don’t know how to bind server-side event for the Class

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:02:54+00:00Added an answer on June 13, 2026 at 6:02 am

    this depends a lot on your code to generate the PDF and EXCEL files, there are several ways to “bind” those buttons to generate the files.

    1. In the same action that renders the grid view in the first place
    2. different actions that use the same code base that generates the CDataProvider.

    for the first case, you can pass a parameter to the action that tells it to generate the corresponding file:

    <?php 
    public function actionIndex()
    {
      //Code base to generate the CActiveData provider.
    
      //Check if we are asking for the PDF version
      if(isset($_GET["pdf"])){
        //Your code to generate the PDF
      }elseif (isset($_GET["excel"])) {
        //Your code to generate the EXCEL
      }else{
        //render the view with the Grid
      }
    }
    
     ?>
    

    Then in your MyGridClass, just point your buttons to the corresponding url:

    //For the pdf
    Yii::app()->controller->createUrl('', array('pdf' => '1'));
    //For the excel
    Yii::app()->controller->createUrl('', array('excel' => '1'));
    

    You can adjust this to have 2 separate actions if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a class that implements the IGroupPolicyObject Interface in COM. one of the
I wrote a class inherited from wxDialog. I'm currently on Ubuntu 12.04, using Code::Blocks
I wrote a class which contains a few variabes: public class myButton extends Sprite{
I wrote some class that extends TextView And now, I want to use this
I wrote a class in C++/CLI which inherits from System.Windows.Forms.UserControl . It works fine,
I wrote a class MyIntent which extends Intent. and then i use an instance
Here is a related manager I wrote: class PortfolioItemManager(models.Manager): use_for_related_fields = True def extended(self):
Okay, so i have this code i wrote: class Connection { public static StreamWriter
I wrote simple class that on the start it just increase the value of
I wrote this class that draws a animated progress with a circle (it draws

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.