nayjest / grids Goto Github PK
View Code? Open in Web Editor NEWGrids framework for Laravel
License: MIT License
Grids framework for Laravel
License: MIT License
FYI, "illuminate/html" should be replaced with "laravelcollective/html" as the former is no longer supported and the latter contains additional methods too (such as a numeric field etc.)
"require": {
"nayjest/grids": "~0.8",
"illuminate/html": "~5"
},
"require": {
"nayjest/grids": "~0.8",
"laravelcollective/html": "~5.0"
},
More information can be found here...
Unknown method "ServiceProvider::package()"
$grid->renderComponents('some section') in main template
Hey Man,
i've some troubles filtering a column of the grid with my data, and i was wondering if you could help me or tell me that what i'm doing is wrong :)
So my dataset is a join between client and invoices.
On a column of my grid i display the client who own the invoice. So in the setCallBack method i use the client_id in the invoice to retreive is name :
->setCallback(function ($val) {
$client_intitule = DB::select("SELECT clients_raison_sociale FROM tri_clients WHERE clients_id = ?",array($val));
foreach($client_intitule as $ci){
$clients_raison_sociale = $ci->clients_raison_sociale;
}
return $clients_raison_sociale;
})
This is working fine :)
But now i want to add a filter on the name of the client but i have only the id of the client in my dataset so i can only filter on his id.
I read somewhere about the "setFilteringFunc" and i tried something like:
->setFilteringFunc(function($val, EloquentDataProvider $provider) {
$builder = $provider->getBuilder();
echo $val;
$builder->where('tri_clients.clients_raison_sociale', 'like', "$val");
})
But i can't get it working, but the $val in filteringFunc is the filter input of the user.
Do you have any idea what i'm doing wrong ?
Grid::STATE_INITIALIZED,
Grid::STATE_PREPARED,
Grid::STATE_RENDERED
I am using an eager loaded query builder and yet I can see that my relations are still getting queried for each row...
$grid = new Grid(
(new GridConfig)
->setDataProvider(
new EloquentDataProvider(Customer::with('Country'))
)
->setName('Customers')
->setPageSize(50)
->setColumns([
(new FieldConfig)
->setName('country.name')
->setLabel('Country')
->setSortable(true)
....
Hi , is there option in SelectFilter for ading id on each select filter ????
I have this:
(new SelectFilter)
->setDefaultValue('g_name')
->setName('Group Name')
->setVariants([$group_name])
->setFilteringFunc(
(function($val, EloquentDataProvider $dp) {
/** @var Illuminate\Database\Eloquent\Builder $builder */
$builder = $dp->getBuilder();
$builder->where('group.id', 'like', $val);
//dd($builder);
})
)
But i also i have more so i want to identify each of them to be different ???
A full tutorial (or documentation) for a crud using Grids would be wonderful for a beginner.
My app is a client app, not make use from Eloquent or Droctrine, query, etc. My data source is my external API. So, how to populate a grid from a stdclass object? My API return json string so I get a StdClass object with json_decode.
to have possibility of adding components via event handler without need of its manual initialization.
if i use csv export component, the start from the document included in csv file.
$grid = new Grid(
(new GridConfig)
..... some fields ....
->setComponents([
(new THead)
,
(new TFoot)
->addComponent(
(new CsvExport)
)
])
Export starts with
<section class="main-content">
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading lead">Grid-Header</div>
<div class="panel-body">
<div class="table-responsive">
Hey men, firstable awesome work here, thanks a lot.
Do you know if it's possible to overwrite the path of the grid pager in the grid declaration (in controllers) ?
I need to overwrite it and i changed in Pager :
$paginator = $this->grid->getConfig()
->getDataProvider()
->getPaginator();
$paginator->setPath("/extranet/public/client");
Is it possible to use something like :
(new OneCellRow)
->setComponents([
(new Pager)
->setPath('/extranet/public')
]).
Thanks a lot for what you've done and sorry if my question is in the wrong place.
Louis
https://github.com/Nayjest/ViewComponents repository contains core classes for view components, extracted from nayjest/grids package and improved.
Submit filter data on select change.
This would be really nice usability improvement.
Thx
When I change the shown columns the button gets hidden behind the drop down check box.
How can I fix this on the mean time?
Class 'Grid' not found !!
would you please tell me the 'providers' and 'aliases' to put in app.php file?
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Method Nayjest\Grids\Grid::__toString() must not throw an exception
getting this error if i set each file in the aliases array
How can i use DateRangePicker?
Is there any documentation?
ccc
E.g user 1
is on page 4 of 5 available.
user 2
delete all items on page 4 and 5.
user 1
try to navigate to page 5 and get empty page.
It would be better if user were redirected to last available page.
My workaround is using laravel pagination before initialize grid.
Is there any better way to solve this problem?
$contracts = Contract::paginate(10);
$currPage = \Illuminate\Support\Facades\Request::get('contract')['page'];
if ((int)$currPage > $contracts->lastPage()){
$url = action('ContractController@index', ['contract' => ['page' => $contracts->lastPage()]]);
return redirect($url);
}
$grid = new Grid(
(new GridConfig)
...
How would I go about adding onclicks/ids/classes to each row of the grid if I wanted each row to be a unique link?
How do i show following output in footer or header?
"Showing 1-50 of 10000"
possible?
How can i customise blades?
I have tried to update published blades from app/resources/views/nayjest/grids/default/*
, but still get output from vendor directory (app/vendor/nayjest/grids/resources/views
)
There is no need for class_alias('\\Nayjest\\Grids\\Grids', '\\Grids');
in the Grids ServiceProvider. It is confusing phpspec with the error below.
If a regular Laravel class alias is added, I don't see this problem:
\Illuminate\Foundation\AliasLoader::getInstance(['Grids' => 'Nayjest\Grids\Grids'])->register();
This can also be put in the config/app.php
file as well to give developers more control.
[ErrorException]: Cannot redeclare class \Grids
Exception trace:
() at vendor/nayjest/grids/src/ServiceProvider.php:45
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
class_alias() at vendor/nayjest/grids/src/ServiceProvider.php:45
Nayjest\Grids\ServiceProvider->boot() at n/a:n/a
call_user_func_array() at vendor/laravel/framework/src/Illuminate/Container/Container.php:523
Illuminate\Container\Container->call() at vendor/laravel/framework/src/Illuminate/Foundation/Application.php:703
Illuminate\Foundation\Application->bootProvider() at vendor/laravel/framework/src/Illuminate/Foundation/Application.php:685
Illuminate\Foundation\Application->Illuminate\Foundation\{closure}() at n/a:n/a
array_walk() at vendor/laravel/framework/src/Illuminate/Foundation/Application.php:686
Illuminate\Foundation\Application->boot() at vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php:15
Illuminate\Foundation\Bootstrap\BootProviders->bootstrap() at vendor/laravel/framework/src/Illuminate/Foundation/Application.php:181
Illuminate\Foundation\Application->bootstrapWith() at vendor/benconstable/phpspec-laravel/src/PhpSpec/Laravel/Util/Laravel.php:100
PhpSpec\Laravel\Util\Laravel->createApplication() at vendor/benconstable/phpspec-laravel/src/PhpSpec/Laravel/Util/Laravel.php:59
PhpSpec\Laravel\Util\Laravel->refreshApplication() at vendor/benconstable/phpspec-laravel/src/PhpSpec/Laravel/Listener/LaravelListener.php:54
PhpSpec\Laravel\Listener\LaravelListener->beforeSpecification() at n/a:n/a
call_user_func() at vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:164
Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php:53
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at vendor/phpspec/phpspec/src/PhpSpec/Runner/SpecificationRunner.php:51
PhpSpec\Runner\SpecificationRunner->run() at vendor/phpspec/phpspec/src/PhpSpec/Runner/SuiteRunner.php:56
PhpSpec\Runner\SuiteRunner->run() at vendor/phpspec/phpspec/src/PhpSpec/Console/Command/RunCommand.php:149
PhpSpec\Console\Command\RunCommand->execute() at vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at vendor/phpspec/phpspec/src/PhpSpec/Console/Application.php:85
PhpSpec\Console\Application->doRun() at vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at vendor/phpspec/phpspec/bin/phpspec:26
Hey men, me again :)
Is it possible to access to my column of checkboxes with a all check, all un check and print ids buttons of raw checked by the user ?
Really appreciate some help.
Have a nice day,
Louis.
If i join tables, the initial output is ok. But if i wan't to add a filter, there comes the error message, that column can't be found or there more than one column with the same name (i.e. name). It looks like the filterin doesn't use the select fields.
Data Provider:
$query = new EloquentDataProvider(
Contract::join('products', 'products.id', '=', 'contracts.product_id')
->join('vendors', 'vendors.id', '=', 'products.vendor_id')
->select('contracts.id',
'vendors.name as vendor_name',
)
);
Grid Initialization:
$grid = new Grid(
(new GridConfig)
->setName('filter')
->setDataProvider($query)
->setColumns([
(new FieldConfig)
->setName('id')
->setLabel('#')
,
(new FieldConfig)
->setName('vendor_name')
->setLabel('Vendor')
->addFilter(
(new FilterConfig)
->setName('vendor_name')
->setOperator(FilterConfig::OPERATOR_LIKE)
)
])
);
Error message:
Column not found: 1054 Unknown column 'vendor_name' in 'where clause' (SQL: select count(*) as aggregate from `contracts` inner join `products` on `products`.`id` = `contracts`.`product_id` inner join `vendors` on `vendors`.`id` = `products`.`vendor_id` where `vendor_name` like %Test%)
Can you pls post an example of grid with DBAL source?
Tried but got an error on laravel 5. thanks
FatalErrorException in DbalDataProvider.php line 72: Call to undefined method Illuminate\Pagination\Paginator::make()
FatalErrorException in EloquentDataProvider.php line 64:
Call to undefined method Illuminate\Database\MySqlConnection::getPaginator()
$fitlers_row = $cfg->getComponentByNameRecursive(FiltersRow::NAME);
returns null
Is it possible to implement bulk actions? I want to delete multiple rows. I need checkboxes in front of every row and delete selected rows. How could I implement this?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.