-
Notifications
You must be signed in to change notification settings - Fork 76
Components Documentation
Implementation of date range picker for Bootstrap based on dangrossman/bootstrap-daterangepicker javascript library.
This component does not includes javascript & styles required to work with bootstrap-daterangepicker. You need to download mentioned resources and include it manually to your pages/layout, see documentation.
Example:
echo HTML::script('js/jquery.js');
echo HTML::script('js/moment.js');
echo HTML::style('css/bootstrap.css');
echo HTML::script('js/daterangepicker/daterangepicker.js');
echo HTML::style('js/daterangepicker/daterangepicker-bs3.css');
Do not try to add this component to column like instance of Nayjest\Grids\Filter. Use it as regular component.
If you want to render DateRangePicker in place where regular column filters are rendered, place it into corresponding render_section of FiltersRow. Tip: To recieve FiltersRow component, you may use GridConfig::getComponentByNameRecursive():
$filters_row = $grid_config->getComponentByNameRecursive(FiltersRow::NAME)
Or instantiate it when overriding components:
$grid_config->setComponents([
(new THead)
->setComponents([
new ColumnHeadersRow,
$filters_row = new FiltersRow
])
,
new TFoot
])
See complete example:
$filters_row = $grid_config->getComponentByNameRecursive(FiltersRow::NAME);
$filters_row->addComponent(
(new DateRangePicker)
->setName($my_filtered_column_name)
->setRenderSection("filters_row_column_{$my_filtered_column_name}")
->setDefaultValue([null, null])
);
Optins described here has corresponding getters and setters. For example, use setName() and getName() methods for name option
Name | Expacted Value | Description |
---|---|---|
name | string, **required ** | Name of filtered column |
jsOptions | array | Options that will be passed to javascript. See possible options |
template | string | Date range picker control template |
value | [string|null, string|null] | Current filter values (from ,to) |
defaultValue | [string|null, string|null] | Default filter values (from ,to). Set to [null,null] for removing default filters |
filteringFunc | callable | Function that will perform filtering. Accepts filter value as first argument and data provider as second argument |
label | string | Text label |
The component provides control for exporting data to excel.
The component requires maatwebsite/excel package.
If you use Laravel 4, take 1.3 branch.
Install it using Composer:
composer require maatwebsite/excel
After updating composer, add the ServiceProvider to the providers array in config/app.php
'Maatwebsite\Excel\ExcelServiceProvider',
Add this to your aliases:
'Excel' => 'Maatwebsite\Excel\Facades\Excel'
Now ExcelExport ready for usage.
Just place instance of ExcelExport into the place inside grid components tree where you want to render "export" button.
The component renders link to the current URL extended by one GET parameter telling to grids engine that excel file must be passed to browser instead of standerd html output.
It imposes one important restriction to grids usage: grid must be created before any output, i. e. if you use ExcelExport component, you can't construct your grid inside view template.
The component provides control for exporting data to CSV.
The component prints value returned by specified PHP function.
Pass function that will produce required output to RenderFunc constructor argument.
That function will accept Grid instance as first argument and current RenderFunc component as second argument.
Avoid printing html inside function, just return it.
Example:
use Nayjest\Grids\Components\RenderFunc;
use Nayjest\Grids\Components\Grid;
...
$parent->addComponent(new RenderFunc(function(Grid $grid, RenderFunc $component) {
return 'Max page size: ' . $grid->getConfig()->getPageSize();
}));