[Vtigercrm-developers] Filter a popup from another popup

classic Classic list List threaded Threaded
5 messages Options
nab
Reply | Threaded
Open this post in threaded view
|

[Vtigercrm-developers] Filter a popup from another popup

nab
Hi,
I have two pop-ups (UI10 type) in the same custom module, say "mymodule".
The first  popup "Project Name", displays all the projects, the second popup
"Task Name"  displays all the tasks of all the projects. I want to apply a
filter on the second popup so when I select a project from the first popup
it will displays in the second popup "Task name" only the tasks
corresponding to the selected project, or if I can intercept the selected ID
of the first popup I could use it to modify the query of the second popup in
"ListView.php", any idea ?
Regards,



--
Sent from: http://vtiger-crm.2324883.n4.nabble.com/vtigercrm-developers-f4.html
_______________________________________________
http://www.vtiger.com/
Reply | Threaded
Open this post in threaded view
|

Re: Filter a popup from another popup

Alan Lord (News)
Relatively easily done when the user uses the popup (inherit and/or
customise the Popup view and the ListView model classes), but when you
use typeahead search in a UIType 10 field, it's broken unfortunately.

http://code.vtiger.com/vtiger/vtigercrm/issues/1059

HTH


Al


On 06/02/2019 19:47, nab wrote:

> Hi,
> I have two pop-ups (UI10 type) in the same custom module, say "mymodule".
> The first  popup "Project Name", displays all the projects, the second popup
> "Task Name"  displays all the tasks of all the projects. I want to apply a
> filter on the second popup so when I select a project from the first popup
> it will displays in the second popup "Task name" only the tasks
> corresponding to the selected project, or if I can intercept the selected ID
> of the first popup I could use it to modify the query of the second popup in
> "ListView.php", any idea ?
> Regards,
>
>
>
> --
> Sent from: http://vtiger-crm.2324883.n4.nabble.com/vtigercrm-developers-f4.html
> _______________________________________________
> http://www.vtiger.com/
>


_______________________________________________
http://www.vtiger.com/
nab
Reply | Threaded
Open this post in threaded view
|

Re: Filter a popup from another popup

nab
Thank you Alan for this clarification.
If we can find a solution to this issue, it will be really beautiful because
this situation of using  two dependent popups occurs frequently. However,
the solution that I'm sure 100% is to retrieve the id or the name of the
item selected in the pop-up window and use it to modify the ListQuery query
located  in modules / Vtiger / models / ListView.php. In the
"getListViewEntries ($ pagingModel)" function, insert your condition to
modify $ listQuery. In our case, we will use our retreived id or name as a
condition. Now, how can we retreive the selected id from ListView.php file,
Have you an idea?




--
Sent from: http://vtiger-crm.2324883.n4.nabble.com/vtigercrm-developers-f4.html
_______________________________________________
http://www.vtiger.com/
Reply | Threaded
Open this post in threaded view
|

Re: Filter a popup from another popup

Alan Lord (News)
If I understand you right,

You need to use the source fieldname:

> $sourceField = $request->get('src_field');

as the source of the popup (so you know which popup your custom query
should relate to), then have a custom function to retrieve whatever
value you need, e.g. from your first UIType10 field, then pass this to
the ListView model.

But you have to start from the Popup view class and pass the relevant
information from there into the RelationListView model to use in the query.

But do bear in-mind that none of this will work for the typeahed search
feature of UIType10s as I mentioned previously.


Al


On 07/02/2019 19:32, nab wrote:

> Thank you Alan for this clarification.
> If we can find a solution to this issue, it will be really beautiful because
> this situation of using  two dependent popups occurs frequently. However,
> the solution that I'm sure 100% is to retrieve the id or the name of the
> item selected in the pop-up window and use it to modify the ListQuery query
> located  in modules / Vtiger / models / ListView.php. In the
> "getListViewEntries ($ pagingModel)" function, insert your condition to
> modify $ listQuery. In our case, we will use our retreived id or name as a
> condition. Now, how can we retreive the selected id from ListView.php file,
> Have you an idea?
>
>
>
>
> --
> Sent from: http://vtiger-crm.2324883.n4.nabble.com/vtigercrm-developers-f4.html
> _______________________________________________
> http://www.vtiger.com/
>


_______________________________________________
http://www.vtiger.com/
nab
Reply | Threaded
Open this post in threaded view
|

Re: Filter a popup from another popup

nab
Thank you Alan,
Finally, I find a way to retrieve the selected item from the popup.
Here is the solution:
In the Vtiger.js file, locate for the "getPopUpParams function" and add the
following two lines:
1- var (your_variable_name) = jQuery ('input [name = "your popup's name"]',
container) .val ();
2- in the same function, locate for params = {....} and add
'name_of_your_variable': name_of_your_variable,
And in ListView.php, call your variable: $ your_variable_name = $ _POST
['your_variable_name'];
That's it!
Thank you again Alan for your cooperation.
Regards




--
Sent from: http://vtiger-crm.2324883.n4.nabble.com/vtigercrm-developers-f4.html
_______________________________________________
http://www.vtiger.com/