You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use a 'select' column but the list of values and labels didn't come from source. It came from external parameters.
Looking in the documentation, it seems to be possible to defined the 'values' only in entity annotations.
To do it by code, I found in SelectColumn class a getValues() method but not setvalues().
So I created it
public function setValues($values)
{
return $this->values = $values;
}
and modified the setData() to
public function setData($data)
{
if ((is_string($data) || is_integer($data)) && $data != $this::BLANK)
{
$this->data = $data;
}
return $this;
}
But doing this could disturb others using. Can somebody confirm it is or not not problematic ?
If no maybe it would be interesting to add it in next commit.
I deleted it because my setdata() call is done after the setSource(). And it is in the setSource() that column values are initialized. If I don't delete the '&& key_exists($data, $this->values)', my filter doesn't work anymore (but column rendering is good).
Of course I can create a new class if it won't be included in a next commit.
I suppose SourceSelectColumn uses a doctrine source to populate de values of the select field.
Can you give us a sample ? I didn't find anything in the documentation.
C'est pour ça que je disais que pour faire un sourceselect sur un champs en jointure, mon exemple ne suffit pas. De même pour un champs avec une fonction d'aggrégation DQL.
Dans ton cas, quelque chose comme ça devrait faire affaire :
Abhoryo: I like you solution. The only problem is that it can't make joins automatically. May be this could lead to feature suggestion to doctrine development.
I would like to have as many joins as possible in distinctQuery
for example, when selecting from table a, column b.c.d.e
it would be splitted like
select distinct _d.e from A _a join _a.b _b join _b.c _c join _c.d _d
etc.
Activity
Abhoryo commentedon Apr 23, 2012
Why do you have to delete this part of this condition in the setData method?
&& key_exists($data, $this->values)You can create a new class like the SourceSelectColumn class too.
olivier3400 commentedon Apr 23, 2012
I deleted it because my setdata() call is done after the setSource(). And it is in the setSource() that column values are initialized. If I don't delete the '&& key_exists($data, $this->values)', my filter doesn't work anymore (but column rendering is good).
Of course I can create a new class if it won't be included in a next commit.
Abhoryo commentedon Apr 23, 2012
Ok, I understand your case. Oki you can do it.
olivier3400 commentedon May 12, 2012
I suppose SourceSelectColumn uses a doctrine source to populate de values of the select field.
Can you give us a sample ? I didn't find anything in the documentation.
Thanks
Abhoryo commentedon May 12, 2012
You only have to force the type of your column in the annotation:
@GRID\Column(type="sourceselect")and implements the method findDistinctByField in your entity repository:
Your entity:
Your entity Repository:
And change this query for mapping fields, you have to deal with a join table, etc...
And yes it uses the doctrine source to populate the values of the select field.
We'll try later to implement it on the vector source.
olivier3400 commentedon May 13, 2012
Merci, ça fonctionne parfaitement
olivier3400 commentedon May 13, 2012
Par contre il ne fonctionne pas avec les entités ManyToOne du type
J'obtiens un message du genre
[Syntax Error] Expected PlainValue, got ''' at position 119 in property ...
Abhoryo commentedon May 13, 2012
C'est pour ça que je disais que pour faire un sourceselect sur un champs en jointure, mon exemple ne suffit pas. De même pour un champs avec une fonction d'aggrégation DQL.
Dans ton cas, quelque chose comme ça devrait faire affaire :
Bref, ce n'est pas optimiser pour tous les cas mais les exemples donnés te permettront de faire ce que tu veux.
olivier3400 commentedon May 14, 2012
Pour info, il faut renvoyer un résultat avec le nom du champ complet.
une bidouille du style peut résoudre le pb mais c'est pas très pro
Abhoryo commentedon May 14, 2012
La question est, mettre en place un système qui ne nécessite pas l'ajout d'une fonction de recherche par champs distinct ?
rfojta commentedon May 29, 2012
Abhoryo: I like you solution. The only problem is that it can't make joins automatically. May be this could lead to feature suggestion to doctrine development.
I would like to have as many joins as possible in distinctQuery
for example, when selecting from table a, column b.c.d.e
it would be splitted like
select distinct _d.e from A _a join _a.b _b join _b.c _c join _c.d _d
etc.
rfojta commentedon May 29, 2012
Abhoryo commentedon May 29, 2012
I'll try your code.
I code DGB 2.0 and I've implemented a new dynamic select column which pick values from the query itself.
Abhoryo commentedon Jun 6, 2012
I have problems with dql functions.
It try this query
select count(*) as scrl1 from TrucMuche Where scrl1 = 12;instead of
select count(*) as scrl1 from TrucMuche having count(*) = 12;Bup3 commentedon Mar 14, 2014
Is it possible to use this today? @Abhoryo
I have for example this column.
But there is no ":last" function => also I get an error.
At the moment I use this function to render the cell.
But I want to sort and filter 👿
With that I can't order or search/filter the field...
Thanks for your help 👍
Abhoryo commentedon Mar 14, 2014
You should have a creation date for each message so you can use a DQL function to sort this column.
Bup3 commentedon Mar 14, 2014
@Abhoryo And how i could display the "message" field of the :max message?
like: messages:last.message
^^