Yii Framework Forum: Tlbexcelview-Related Discussion, Questions, And Issues - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Tlbexcelview-Related Discussion, Questions, And Issues Please use this thread for any issue related to tlbExcelView widget Rate Topic: -----

#21 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 01 April 2013 - 07:20 AM

It seems all the filter inputs are empty. Have you actually put data in?

Can you also inspect the page and see if there are any JS errors.

If you can put the page online, that would be helpful as well.
0

#22 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 27 April 2013 - 12:46 PM

v1.1 is uploaded and adds RTL support. Please see extension homepage or Github repository.
0

#23 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 06 June 2013 - 11:56 AM

View Postbennouna, on 22 January 2013 - 12:41 PM, said:

Thanks, a great share of credit should go to phreak for the original extension.

Anyway, for the zoom scale, you're probably right, it should be at most an option that could be set in the widget.


A fellow Github member contributed with that feature / option which I've merged into tlbExcelView’s repository.
0

#24 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 13 June 2013 - 03:37 PM

Was this solved? I am having similar problems.

Error 404:
The system is unable to find the requested action "Admin?".
0

#25 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 June 2013 - 05:12 PM

Hello davelaser

Was what solved?

Please post your controller + view codes

Cheers
0

#26 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 13 June 2013 - 05:41 PM

View Postbennouna, on 13 June 2013 - 05:12 PM, said:

Hello davelaser

Was what solved?

Please post your controller + view codes

Cheers


When I click the export button I get the message:

ERROR 404
The system is unable to find the requested action "admin?".


Here's what I have for code. Thanks!

Controller Code

	public function actionAdmin()
	{
		$model=new Weeklyservicereport('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Weeklyservicereport']))
			$model->attributes=$_GET['Weeklyservicereport'];
                
                //new stuff for excel export
                if(isset($_GET['export'])){
                    $production = 'export';
                }else{
                    $production = 'grid';
                }
                $this->render('admin', array('model' => $model, 'production' => $production));
                /*before excelview
		$this->render('admin',array(
			'model'=>$model,
		));
                 * 
                 */
	}


View Code

<div class="row buttons">
        <?php echo CHtml::button(Yii::t('app', 'Export to Excel (xls)'), array('id' => 'exportToExcel')); ?>
</div>

<?php $this->widget('application.components.widgets.tlbExcelView', array(
	'id'=>'weeklyservicereport-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
        
        
	'columns'=>array(
                'CompName',
                'ShipCity',
                'Contact',
		'Model',
                'esl_SN',
		'ServDate', 
                'ServDate2',
		'ServiceEmployee',		
		'ServDesc',
                
		
		/*
                'ServOnSite',
		'ei_SN',
		'ei_LocID',
		'cl_LocID',
		'cl_CompID',
		'cn_CompID',
		
		*/
	),
)); ?>

0

#27 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 June 2013 - 06:04 PM

I imagine you have a partial view rendered somewhere, and a registered script for the exportToExcel button? Could you also post them it?

EDIT


View Postdavelaser, on 13 June 2013 - 05:41 PM, said:

<?php $this->widget('application.components.widgets.tlbExcelView', array(
	'id'=>'weeklyservicereport-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,

        // Missing line?
        
	'columns'=>array(
		…
	),
)); ?>



You're also missing this line
	'grid_mode' => $production,

This post has been edited by bennouna: 13 June 2013 - 06:10 PM

0

#28 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 13 June 2013 - 06:13 PM

View Postbennouna, on 13 June 2013 - 06:04 PM, said:

I imagine you have a partial view rendered somewhere, and a registered script for the exportToExcel button? Could you also post them?


Thanks for being patient with me :)

I don't think I have a partial view rendered, but here's the export script.


Script:

$('#exportToExcel').click(function(){
        window.location = '". $this->createUrl('admin')  . "?' + $(this).parents('form').serialize() + '&export=true';
        return false;
    }); 

0

#29 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 June 2013 - 06:25 PM

I'm sorry but I edited my post before yours, what about the missing line?

Also, normally the script should be registered by Yii:
<?php Yii::app()->clientScript->registerScript('search', "
    $('#exportToExcel').click(function(){
        window.location = '". $this->createUrl('admin')  . "?' + $(this).parents('form').serialize() + '&export=true';
        return false;
    });
"); ?>

0

#30 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 13 June 2013 - 06:38 PM

View Postbennouna, on 13 June 2013 - 06:25 PM, said:

I'm sorry but I edited my post before yours, what about the missing line?

Also, normally the script should be registered by Yii:
<?php Yii::app()->clientScript->registerScript('search', "
    $('#exportToExcel').click(function(){
        window.location = '". $this->createUrl('admin')  . "?' + $(this).parents('form').serialize() + '&export=true';
        return false;
    });
"); ?>




Ok, the script is registered I just left out that line. I added the missing line you suggested, and i'm still getting the same result.
0

#31 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 13 June 2013 - 11:54 PM

Can you put that app online, at least that controller and view?
0

#32 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 14 June 2013 - 12:19 PM

View Postbennouna, on 13 June 2013 - 11:54 PM, said:

Can you put that app online, at least that controller and view?


Is it a problem that I am not using the "Advanced Search" form for entries and just the gridview ? It looks like this may be meant for the search form, but the data exported should still be the same.
0

#33 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 14 June 2013 - 12:26 PM

View and controller as requested.

View:

<?php
/* @var $this WeeklyservicereportController */
/* @var $model Weeklyservicereport */

$this->breadcrumbs=array(
	'Weeklyservicereports'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Weeklyservicereport', 'url'=>array('index')),
	array('label'=>'Create Weeklyservicereport', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
    
$('#exportToExcel').click(function(){
        window.location = '". $this->createUrl('admin')  . "?' + $(this).parents('form').serialize() + '&export=true';
        return false;
    });    
    
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#weeklyservicereport-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Service Report</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>


<div class="row buttons">
        <?php echo CHtml::button(Yii::t('app', 'Export to Excel (xls)'), array('id' => 'exportToExcel')); ?>
</div>

<?php $this->widget('application.components.widgets.tlbExcelView', array(
	'id'=>'weeklyservicereport-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
        'grid_mode' => $production,
        
	'columns'=>array(
                'CompName',
                'ShipCity',
                'Contact',
		'Model',
                'esl_SN',
		'ServDate', 
                'ServDate2',
		'ServiceEmployee',		
		'ServDesc',
                
		
		/*
                'ServOnSite',
		'ei_SN',
		'ei_LocID',
		'cl_LocID',
		'cl_CompID',
		'cn_CompID',
		
		*/
	),
)); ?>


Controller:

<?php

class WeeklyservicereportController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column1';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'postOnly + delete', // we only allow deletion via POST request
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view'),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('admin','delete'),
				'users'=>array('admin'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	/**
	 * Displays a particular model.
	 * @param integer $id the ID of the model to be displayed
	 */
	public function actionView($id)
	{
		$this->render('view',array(
			'model'=>$this->loadModel($id),
		));
	}

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Weeklyservicereport;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Weeklyservicereport']))
		{
			$model->attributes=$_POST['Weeklyservicereport'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->esl_SN));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}

	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id)
	{
		$model=$this->loadModel($id);

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Weeklyservicereport']))
		{
			$model->attributes=$_POST['Weeklyservicereport'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->esl_SN));
		}

		$this->render('update',array(
			'model'=>$model,
		));
	}

	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		$this->loadModel($id)->delete();

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_GET['ajax']))
			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
	}

	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
		$dataProvider=new CActiveDataProvider('Weeklyservicereport');
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
		));
	}

	/**
	 * Manages all models.
	 */
	public function actionAdmin()
	{
		$model=new Weeklyservicereport('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Weeklyservicereport']))
			$model->attributes=$_GET['Weeklyservicereport'];
                
                //new stuff for excel export
                if(isset($_GET['export'])){
                    $production = 'export';
                }else{
                    $production = 'grid';
                }
                $this->render('admin', array('model' => $model, 'production' => $production));
                /*before excelview
		$this->render('admin',array(
			'model'=>$model,
		));
                 * 
                 */
	}

	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer $id the ID of the model to be loaded
	 * @return Weeklyservicereport the loaded model
	 * @throws CHttpException
	 */
	public function loadModel($id)
	{
		$model=Weeklyservicereport::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}

	/**
	 * Performs the AJAX validation.
	 * @param Weeklyservicereport $model the model to be validated
	 */
	protected function performAjaxValidation($model)
	{
		if(isset($_POST['ajax']) && $_POST['ajax']==='weeklyservicereport-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}
	}
}


0

#34 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 14 June 2013 - 06:04 PM

Your case is at least different in that there's no form so no need to send the serialized form data.

You'll have to be are able to provide an online testing page or the Firebug console output if you'd like me to debug your code. A 404 error means not found resource (url), and I doubt the above is the only reason it doesn't work. Maybe you have some settings in your URL manager or you can try with $this->createUrl('controller/action')

That said, you can see how it works without the form is this fiddle: http://jsfiddle.net/tellibus/emzhQ/, and your problem does not seem consistent. But obviously you should slightly adapt your JS code to remove the serialize and the '&' part.
1

#35 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 17 June 2013 - 04:49 PM

Thanks again for all of your help.

I haven't done much with Firebug. Just downloaded FF and installed it. What exactly would you need to help you debug? The console is currently giving me one error when I hit the export button.

"NetworkError: 404 Not Found - http://localhost/ecc2/index.php?r=Weeklyservicereport/admin?&export=true"


Let me know what else would help.
0

#36 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 June 2013 - 05:53 PM

Hmm so you're not in url path mode. I should have said so in the extension page, sorry for that!

So in your case, you should resolve the issue by one of two methods: setting the urlFormat to 'path' OR by changing your view code to:

Yii::app()->clientScript->registerScript('search', "
    
    $('#exportToExcel').click(function(){
        // If your urlFormat is set to 'path'
        // window.location = '". $this->createUrl('admin')  . "?' + $(this).parents('form').serialize() + '&export=true';
        // Otherwise:
        window.location = '". $this->createUrl('admin')  . "&export=true';
        // Comment the above lines and uncomment the following one if you have a search form and your urlFormat is NOT 'path':
        // window.location = '". $this->createUrl('admin')  . "&' + $(this).parents('form').serialize() + '&export=true';
        return false;
    });    

");

1

#37 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 17 June 2013 - 06:18 PM

Thanks Bennouna!

This was exactly the issue. You're a genius!

Now it appears that the export button is trying to send ALL of the results instead of the results AFTER the search filters are applied.

I feel like I've seen this issue before but I couldn't find it on the forum, are you aware of a fix for this?

Thanks again.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in C:\xampp-portable\htdocs\ecc2\protected\extensions\phpexcel\Classes\PHPExcel\Style\Supervisor.php on line 123

0

#38 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 17 June 2013 - 07:04 PM

View Postdavelaser, on 17 June 2013 - 06:18 PM, said:

Thanks Bennouna!

This was exactly the issue. You're a genius!

Now it appears that the export button is trying to send ALL of the results instead of the results AFTER the search filters are applied.

I feel like I've seen this issue before but I couldn't find it on the forum, are you aware of a fix for this?

Thanks again.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in C:\xampp-portable\htdocs\ecc2\protected\extensions\phpexcel\Classes\PHPExcel\Style\Supervisor.php on line 123



Not exactly sure what was happening, but I've managed to fix this. I had to put the button inside of the __search form to get it to export properly. I had it between the search form and the DataGrid which was causing an error.
0

#39 User is offline   davelaser 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 28-May 13

Posted 18 June 2013 - 06:45 PM

Hello again,

Is there a way to do more detailed formatting in tlbExcelView?

I'd like to add images and display data similar to something like this.

PHPExcel Demo
0

#40 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 19 June 2013 - 03:19 AM

Hello.

A way would be to fork the widget and code everything you need.

But personally, I use the PDF format for invoices, and I don't use CGridView as an output: I put the needed format in a view, and I render it as a PDF. If it's an option for you, you can see what http://mpdf1.com (for example) can do. It even has an extension : http://www.yiiframew...m/extension/pdf
1

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • 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