Comments (15)
You use the same object twice. You have to call again the grid
service.
<?php
// First Grid
$grid1 = $this->get('grid');
$grid1->setId('grid1');
$source1 = new Entity(OneEntity);
$grid1->setSource($source1);
// And now the second:
$grid2 = $this->get('grid');
$grid2->setId('grid2');
$source2 = new Entity(SecondEntity);
$grid2->setSource($source2);
if ( $grid1->isReadyForRedirect() || $grid2->isReadyForRedirect() )
{
// Data are stored, do redirect
return new RedirectResponse($this->generateUrl($this->getRequest()->get('_route')));
}
else
{
// To obtain data for template you need to call prepare function
return $this->render(
'MyProjectMyBundle::my_grids.html.twig',
array(
'data1' => $grid1->prepare(),
'data2' => $grid2->prepare()
)
);
}
Do you confirm @Sorien ?
from apydatagridbundle.
Thanks for the response.
Yes i have taken the same in my testsuite, but the error still is "Source can be set just once".
I think the grid service manage multiple grids with one object by ids the twig tag says:
public function getGrid($grid, $theme = null, $id = '')
The tag gets the grid by id from one grid object.
from apydatagridbundle.
I've never tested multiple grids yet. I'll try to make it work.
from apydatagridbundle.
We'll wait for Sorien :D
from apydatagridbundle.
Ok let's wait, thanks for the trouble!
from apydatagridbundle.
i'm not sure where is problem, it should be working, i'll look at it today ...
for now try this $grid_1 = $this->get('grid'); $grid_2 = clone $grid_1;
or
look at https://github.com/S0RIEN/DataGridBundle/blob/master/Resources/config/services.xml and define new service like
<service id="my_second_grid" class="%grid.base.class%">
<argument type="service" id="service_container" />
</service>
and then
call $this->get('grid') and $this->get('my_second_grid') it should solve your problem
from apydatagridbundle.
I'll already try these solutions and we get another problems.
from apydatagridbundle.
Same here :)
I have checked cloning and this brings trouble with the filter and sortings, the columns from my entitys will be "mixed".
And define a second service in sevice.xml brings this error: No suitable Column Extension found for column type: text
from apydatagridbundle.
ok i've fixed cloning and service so use it like this
$grid = $this->get('grid');
$grid2 = $this->get('grid'); // or clone $grid;
$grid->setSource(new Entity('Invoice:Invoice'));
$grid->setId('first');
$grid2->setSource(new Entity('Invoice:InvoiceReceived'));
$grid2->setId('second');
if ($grid->isReadyForRedirect() || $grid2->isReadyForRedirect())
{
return new RedirectResponse($this->generateUrl($this->getRequest()->get('_route')));
}
else
{
return $this->render('Invoice:Invoice:index.html.twig', array('data' => $grid->prepare(), 'data2' => $grid2->prepare()));
}
pls let me know if its ok
from apydatagridbundle.
It works for me, thx.
from apydatagridbundle.
Thanks!
My 2 grids comes up now, but sorting my grids makes trouble.
I have 2 different entitys on my page with diffrent columns.
When I sort grid1 so grid2 will always be sort if they has a column with the same name.
On sort a column that only exist in one grid i became this error: Column with id "diffrent" doesn't exists".
I think it's a problem with the paramater "grid__id_" on the sort columns, this id is for both grids the same.
from apydatagridbundle.
Ok i think the problem is in the twig function "getGridUrl($section, $grid, $param = null)" or a little deeper in getHash() or getId().
But i have no idea where i can begin to find the error, so i think its a good idea to wait a little for sorien :)
from apydatagridbundle.
i've fixed generating hash in grid, and setId needs to be defined before setting source like example below
$grid = $this->get('grid');
$grid2 = $this->get('grid'); // or clone $grid;
$grid->setId('first');
$grid->setSource(new Entity('Invoice:Invoice'));
$grid2->setId('second');
$grid2->setSource(new Entity('Invoice:InvoiceReceived'));
from apydatagridbundle.
Thanks for your time, it work's now for me.
from apydatagridbundle.
thx for bug reports, closing ticket ...
from apydatagridbundle.
Related Issues (20)
- Is it possible to change groupConcat separator through annotions? HOT 1
- Table very slow with a lot of data HOT 1
- The alias doesn't work to filter the added columns (aggregated column here)
- Yaml configuration for entities HOT 1
- Maintenance & futur of the bundle HOT 16
- ORDER BY on a column from a fetch joined to-many HOT 1
- When creating a RowAction, the route parameter name should be dynamic. HOT 1
- defaultfilter with multiple values and filter=select ? HOT 2
- Travis builds are failing due to composer memory limit HOT 7
- composer require apy/datagrid-bundle fails with symfony 5 HOT 1
- Problem with Export + MassAction
- Filtering on 'not equals to' should return rows with 'null/empty' values
- Routes gets called two times when user filters column HOT 1
- Symfony 5 Support HOT 6
- Bugfix: Trying to access array offset on value of type null (strict types) HOT 8
- PHPExcel is deprecated use PHPSpreadsheet instead HOT 1
- Defining Export and others as Services
- export fails when using custom twigs HOT 5
- Attempted to call an undefined method named "getSQLResultCasing" HOT 2
- Symfony 6.0 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apydatagridbundle.