Comments (34)
you cant define random id couse you need to know it when grid is saving data to session ... dont know if there is way how to have same id for grid in all requests
from apydatagridbundle.
Why not generate an id with all the options defined in a grid ?
Controller, source, columns, action...
from apydatagridbundle.
yes its possible but maybe faster way is one static variable which will be incrementing when you call grids constructor
from apydatagridbundle.
I've already think about that but what if for some reason one grid is not displayed the next filter?
For instance, between 1h00 and 3h00 a grid is not displayed.
Or a grid is only show for Admin and the user rules is changed between two filters.
from apydatagridbundle.
hmmm ... then he will be need to set id manually ... i've created experimental branch with implementation with static variable
from apydatagridbundle.
hashing all object is a bit problematic, i've tried spl_object_hash and so on no one worked like i should, we will need to hash all objects manually, do know if its right way
from apydatagridbundle.
can you look at last commit in branch auto_id_generator its building hash based on controller column and source hash
from apydatagridbundle.
I'll take a look.
from apydatagridbundle.
Not tested yet, but sometimes I use two identical grids.
The first grid shows enabled objects and the second shows the desabled objects.
The hash is identical in these two grid.
Perhaps you can hash the source with its queryBuilder ?
I think that if grids are very similar, a user have to define himself the identifier of the grids.
from apydatagridbundle.
Oh, why $grid->setId is no longer used ?
from apydatagridbundle.
Hum, nothing works :D
I use a simple grid and I have this error :
An exception has been thrown during the rendering of a template ("DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (a:1:{i:0;s:17:"ROLE_PROFILE_EDIT";}) at position 1 (:): Unexpected character") in "SorienDataGridBundle::blocks.html.twig" at line 65.
from apydatagridbundle.
grid need to have prepared columns before creating query it means you can't hash querybuilder, i can readd setId ... which way seems to be better for you, hash or static var?
from apydatagridbundle.
I think generate an auto hash is great but we have to keep the setId way for some case.
When you generate the hash, add the Id to the end of the hash.
controller+column+source+id
(id default=empty)
from apydatagridbundle.
I'm still not sure ... static var is a bit problematic when some grid is ignored and generate hash will cause unexpected odd errors like 2 same grids but filtered for different data with querybuilder callback (you just copy a code but there will be some strange error and you don't know why)... maybe combination static and hash can solve all problems it will take a best of all implementations
from apydatagridbundle.
check last implementation it is using hash generation and static counter ... you can have n same grids and hide filters ... there is just one problem when you are hiding one of same filters there can be situation where second will use data from first
from apydatagridbundle.
I told you to use a hash + an id. Not a counter.
It's not common to have the same grid. A user should know when an identifier for a grid is mandatory.
Maybe you can implement a grid manager that controls these problems.
Example of usage:
<?php
$grid_manager = $this->get('grid.manager');
$grid1 = $grid_manager->create(); // return a grid object
$source1 = new Entity('Entity:User');
$grid1->setSource($source1);
$grid2 = $grid_manager->create();
$source2 = new Entity('Entity:User');
$grid2->setSource($source2);
// The grid manager handle the redirection for all grids create during the request
// If the grid manager detect the same hash for two grid, a exception is thrown
// We have to create a grid with a id: $grid2 = $grid_manager->create('my_grid_2');
if ($grid_manager->isReadyForRedirect())
{
//data are stored, do redirect
return new RedirectResponse($this->generateUrl('grid'));
}
else
{
// to obtain data for template you need to call prepare function
return $this->render('Bundle::grid.html.twig', array('data' => $grid1, 'data2' => $grid2));
}
from apydatagridbundle.
re:"I told you to use a hash + an id. Not a counter." i know that, i'm just trying to find best solution
problem is that I'm not satisfied with static nor hash+id implementation, it's reason why it's not in master ... and grid manager can't solve all problems too, grid manager is same like static implementation but all logic is moved to another class
i was checking another grid implementations and no of them is trying to autogenerate id, they are forcing user to set proper id
from apydatagridbundle.
Do you read my comments in the code?
A grid_manager can easily manage identifier colision, isReadyForRedirect and new features like export data for all grids implement with the manager. We can call it grid.factory if you want.
What's wrong with this solution. Do you want me to implement my solution to test it?
from apydatagridbundle.
dunno if its not too late to detect a collision in isreadyforredirect couse wrong data been stored in setSource ...
it will not working for
if ($time < 0:00){
$grid = $grid_manager->create();
$grid->setSource('FooFaa');
}else{
$grid = $grid_manager->create();
$grid->setSource('FiiFoo');
}
the same problem like with static variable // its not able to check colision couse there is not any and grid filtering can be broken
from apydatagridbundle.
Hmmm, I see what you said. Dammit !
Maybe we can move fetchAndSaveColumnData, executeMassActions and fetchAndSaveGridData + prepare and call them inside a new function.
$grid_manager = $this->get('grid.manager');
$grid1 = $grid_manager->create(); // return a grid object
$source1 = new Entity('Entity:User');
$grid1->setSource($source1);
$grid2 = $grid_manager->create();
$source2 = new Entity('Entity:User');
$grid2->setSource($source2);
/*
* If the grid manager detect the same hash for two grid, a exception is thrown.
* fetchAndSaveColumnData, executeMassActions, fetchAndSaveGridData and prepare are call after the colision detection
*/
$grid_manager->prepare();
/*
* The grid manager handle the redirection for all grids create during the request
*/
if ($grid_manager->isReadyForRedirect())
{
//data are stored, do redirect
return new RedirectResponse($this->generateUrl('grid'));
}
else
{
// to obtain data for template you need to call prepare function
return $this->render('Bundle::grid.html.twig', array('data' => $grid1, 'data2' => $grid2));
}
from apydatagridbundle.
Hi, I finish my own bundle and post-it on github.
After I'll try what I've proposed in my previous post.
from apydatagridbundle.
don't need to hurry up :)
from apydatagridbundle.
Tada ! my first bundle
from apydatagridbundle.
I've started this branch from yours.
I commit an evol with a grid manager.
Generate auto id isn't really possible. This grid manager generates an exception if grids have the same hash and proposes to define an identifier for grids.
$gridManager = $this->get('grid.manager');
$source = new Entity('MyProjectMyBundle:User');
$grid = $gridManager->createGrid($source);
$grid->setSource($source);
$source2 = new Entity('MyProjectMyBundle:User');
$grid2 = $gridManager->createGrid($source2);
$grid2->setSource($source2);
if ($gridManager->isReadyForRedirect()) { // Generate an exception
return new RedirectResponse($this->generateUrl('grid'));
}
else
{
return $this->render('MyProjectMyBundle::grid.html.twig', array('data' => $grid->prepare(), 'data2' => $grid2->prepare()));
}
In addition, I add a method that handles other aspects of grids as the redirection after filtering but also the export of grids for instance.
$gridManager = $this->get('grid.manager');
$source = new Entity('MyProjectMyBundle:User');
$grid = $gridManager->createGrid($source);
$grid->setId("grid1");
$grid->setSource($source);
$source2 = new Entity('MyProjectMyBundle:User');
$grid2 = $gridManager->createGrid($source2);
$grid2->setSource($source2);
if (($manageReturn = $gridManager->manageGrids()) !== false)
{
return $manageReturn;
}
else
{
return $this->render('MyProjectMyBundle::grid.html.twig', array('data' => $grid->prepare(), 'data2' => $grid2->prepare()));
}
from apydatagridbundle.
I'm too busy right now, hope that I'll look at it during a weekend
from apydatagridbundle.
No prob.
from apydatagridbundle.
its a step forward and solving few problems but i'm not sure if i want to have 2 different ways how to create manage/grids
from apydatagridbundle.
Ok, use only the manager to create a grid :D One way!
I just don't want to have this later in each controller:
if (grid1->expor() || grid2->expor() || grid3->expor())
->export
else if (grid1->redirect() || grid2->redirect() || grid3->redirect())
->redirect
else if ...
else if ...
else
-> draw grids
from apydatagridbundle.
one questions how many grids do you have on one page ... i have almost finished shop system for my company and i don't have more then 1 grid per page.
from apydatagridbundle.
Ah good question.
I have a "shop" website too and in the user account, there are 5 grids to show objects, one per state. (draft, wait for validation, In progress, finish, cancel)
from apydatagridbundle.
hmm, ok, i'll marge it but please can you make pr and add some docs (1 example + some comment)
from apydatagridbundle.
Ok no prob, I'll do a PR and change the documentation.
from apydatagridbundle.
pls do not change all samples just add one to "how to manage multiple grids" and mark it as preferred way
from apydatagridbundle.
Yeah, it's what I want to do. Don't worry, I do the PR and you'll merged it.
from apydatagridbundle.
Related Issues (20)
- 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
- allow false for Column Translation Domain
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.