Tlbexcelview-Related Discussion, Questions, And Issues Please use this thread for any issue related to tlbExcelView widget
#21
Posted 01 April 2013 - 07:20 AM
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.
#22
Posted 27 April 2013 - 12:46 PM
#23
Posted 06 June 2013 - 11:56 AM
bennouna, on 22 January 2013 - 12:41 PM, said:
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.
#24
Posted 13 June 2013 - 03:37 PM
Error 404:
The system is unable to find the requested action "Admin?".
#25
Posted 13 June 2013 - 05:12 PM
Was what solved?
Please post your controller + view codes
Cheers
#26
Posted 13 June 2013 - 05:41 PM
bennouna, on 13 June 2013 - 05:12 PM, said:
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',
*/
),
)); ?>
#27
Posted 13 June 2013 - 06:04 PM
EDIT
davelaser, 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
#28
Posted 13 June 2013 - 06:13 PM
bennouna, on 13 June 2013 - 06:04 PM, said:
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;
});
#29
Posted 13 June 2013 - 06:25 PM
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;
});
"); ?>
#30
Posted 13 June 2013 - 06:38 PM
bennouna, on 13 June 2013 - 06:25 PM, said:
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.
#32
Posted 14 June 2013 - 12:19 PM
bennouna, on 13 June 2013 - 11:54 PM, said:
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.
#33
Posted 14 June 2013 - 12:26 PM
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><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></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();
}
}
}
#34
Posted 14 June 2013 - 06:04 PM
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.
#35
Posted 17 June 2013 - 04:49 PM
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.
#36
Posted 17 June 2013 - 05:53 PM
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;
});
");
#37
Posted 17 June 2013 - 06:18 PM
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
#38
Posted 17 June 2013 - 07:04 PM
davelaser, on 17 June 2013 - 06:18 PM, said:
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.
#39
Posted Yesterday, 06:45 PM
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
#40
Posted Today, 03:19 AM
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

Help













