Skip to content

Instantly share code, notes, and snippets.

@abennouna
Last active December 17, 2015 02:59
Show Gist options
  • Save abennouna/5539972 to your computer and use it in GitHub Desktop.
Save abennouna/5539972 to your computer and use it in GitHub Desktop.
Le Lab by tellibus : tlbExcelView - http://tellibus.com/lab/tlbExcelView/
<?php public function actionAdmin() {
$model = new Model('search');
$model->unsetAttributes();
if (isset($_GET['Model'])) {
$model->attributes = $_GET['Model'];
}
if (isset($_GET['export'])) {
$production = 'export';
} else {
$production = 'grid';
}
$this->render('admin', array('model' => $model, 'production' => $production));
} ?>
<?php Yii::app()->clientScript->registerScript('search', "
$('#exportToExcel').click(function(){
window.location = '". $this->createUrl('admin') . "?' + $(this).parents('form').serialize() + '&export=true';
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('some-grid', {
data: $(this).serialize()
});
return false;
});
"); ?>
<div class="search-form" style="display:block">
<?php $this->renderPartial('_search', array('model' => $model)); ?>
</div><!-- search-form -->
<?php $this->widget('application.components.widgets.tlbExcelView', array(
'id' => 'some-grid',
'dataProvider' => $model->search(),
'grid_mode' => $production,
'title' => 'Nom du classeur - ' . date('d-m-Y - H-i-s'),
'creator' => 'Votre nom',
'subject' => mb_convert_encoding('Etat de production généré le ' . utf8_encode(strftime('%e %B %Y')), 'ISO-8859-1', 'UTF-8'),
'description' => mb_convert_encoding('Etat de production généré à la demande.', 'ISO-8859-1', 'UTF-8'),
'lastModifiedBy' => 'Votre nom',
'sheetTitle' => 'Etat du ' . date('m-d-Y H-i'),
'landscapeDisplay' => true,
'A4' => true,
'pageFooterText' => '&RPage n° &P sur &N',
'automaticSum' => true,
'decimalSeparator' => ',',
'thousandsSeparator' => '.',
'sumLabel' => 'Totaux des colonnes :',
'borderColor' => '00FF00',
'bgColor' => 'FFFF00',
'textColor' => 'FF0000',
'rowHeight' => 45,
'headerBorderColor' => 'FF0000',
'headerBgColor' => 'CCCCCC',
'headerTextColor' => '0000FF',
'headerHeight' => 10,
'footerBorderColor' => '0000FF',
'footerBgColor' => '00FFCC',
'footerTextColor' => 'FF00FF',
'footerHeight' => 50,
'columns' => $grid
)); ?>
<?php $form = $this->beginWidget('GxActiveForm', array(
'action' => Yii::app()->createUrl($this->route),
'method' => 'get',
)); ?>
<div class="row buttons">
<?php echo GxHtml::submitButton('Rechercher'); ?>
<?php echo GxHtml::button('Exporter vers Excel (xls)', array('id' => 'exportToExcel')); ?>
</div>
<?php $this->endWidget(); ?>
@abennouna
Copy link
Author

La page officielle du widget se trouve sur http://tellibus.com/lab/tlbExcelView

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment