ButtonTableExport widget is a wrapper for the 2amigOS! TableExport jQuery plugin. It provides a number of options to export an HTML table in different formats.
The current supported formats are:
- json
- csv
- html
- excel
The plugin can also be used separately, that is, by using ButtonTableExportTable and registering its assets. By doing it, you could configure any click'able HTMLElement on your page.
The widget extends yii\bootstrap\DropdownButton
, therefore, you can use all its properties.
Installation ¶
The preferred way to install this extension is through composer.
Either run ~~~ php composer.phar require "2amigos/yii2-table-export-widget" "*" ~~~
or add
"2amigos/yii2-table-export-widget" : "*"
to the require section of your application's composer.json
file.
Usage ¶
Using data-uri
method. Please, check http://caniuse.com/#feat=datauri to find out
about browser support for this method.
use dosamigos\tableexport\ButtonTableExport;
echo ButtonTableExport::widget([
[
'label' => 'Export Table Grid',
'selector' => '#my-grid-id > table', // from a grid
'split' => true,
'exportClientOptions' => [
'ignoredColumns' => [0, 7], // lets ignore some columns
'useDataUri' => true,
]
]
]);
Using TableExportAction
- the most reliable option:
// On your controller
use dosamigos\tableexport\ButtonTableExport;
// ...
public function actions()
{
return [
// ...
'download' => [
'class' => TableExportAction::className()
]
// ...
];
}
// ...
// On your view
use dosamigos\tableexport\ButtonTableExport;
<?= ButtonTableExport::widget(
[
'label' => 'Export Table',
'selector' => '#tableId', // any jQuery selector
'exportClientOptions' => [
'ignoredColumns' => [0, 7],
'useDataUri' => false,
'url' => \yii\helpers\Url::to('controller/download')
]
]
);?>
Using it manually
<?php
// On your view
use dosamigos\tableexport\ButtonTableExportAsset;
ButtonTableExportAsset::register($this);
?>
<a id="linkId" >Export Table as Xml</a>
// On your javascript file
$('#linkId').tableExport({
type: "xml",
useDataUri: true
});
Resources ¶
web development has never been so fun
www.2amigos.us
Abandoned
Unfortunately, this extensions has abadoned. I want to use selector export but it isn't work anymore...
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.