filter dropdownlist

rluongo 30 Jan, 2017
Hello everyone,
I have a form that displays data in a table.
done with crhonoconnectivity v5.
in this table I have two fields that I want to filter with two dropdownlist.
how is that possible?
I found how to search by entering text but not with dropdownlist.
you can tell me some guidance or suggestions?
thank you so much
simelas 30 Jan, 2017
Answer
1 Likes
Hi rluongo,

I think Bob or Max already expalined that somewhere in the forum...

Just in case: use a chronoform code like this one:

<?php

    $keys = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($rows, explode(".", "[n].YOURMODEL")), explode(".", "[n].YourFieldName"));
        $values = \GCore\Libs\Arr::getVal(\GCore\Libs\Arr::getVal($rows, explode(".", "[n].YOURMODEL")), explode(".", "[n].YourFieldName"));
        $options = array_combine($keys, $values);
        $field = array 
        (
          'name' => 'fltr[YOURMODEL][YourFieldName]',
          'id' => '',
          'options' => 
          array (
          ),
          'empty' => ' Search Name',
          'values' => 
          array (
          ),
          'label' => 
          array (
            'text' => '',
            'position' => 'left',
          ),
          'sublabel' => '',
          'multiple' => '0',
          'size' => '',
          'class' => '',
          'title' => '',
          'style' => '',
          'params' => '',
          ':data-load-state' => '',
          ':data-tooltip' => '',
          'type' => 'dropdown',
          'container_id' => '0',
        );
        $field["options"] = $options;
        echo \GCore\Helpers\Html::formLine($field["name"], $field);
        echo '<div class="form-group gcore-form-row" id="form-row-1"></div>';             
?>
rluongo 31 Jan, 2017
Thank you so much Simelas,
I am a beginner, but I think I understand the operation of the script that you wrote kindly.
can you please describe it and tell me where to add?
Thanks again.
Max_admin 31 Jan, 2017
Hi rluongo,

The script should be added to the header section of the listing.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rluongo 01 Feb, 2017
Thanks Max,
Unfortunately, being a beginner I did not understand how to fill it .... I would need some explanation to understand the functioning of the script so that you can fill out correctly.
could someone, politely, illustrate it?
thanks a lot to everyone
simelas 02 Feb, 2017
1 Likes
Hi rluongo,

It is quite simple to do it:

in settings >>> Columns list you put a field like YOURMODEL.YourFieldName: Title

in List display >>> Table >>> Header code you add the script as provided and it should be ok
Best,

simelas
rluongo 06 Feb, 2017
Hello everyone and thanks for the answers,
I did some tests but I sript works in part and I can not figure out where I'm wrong, I try to explain what I'd need:
I have three related tables in a connection, questions table, table category, subcategory table.
questions table: idquestion, question, answer 1, answer 2, answer 3, CategoryID, idsubcategory.
Table category: CategoryID, description category.
Table subcategory: idsubcategory, description subcategory.
the page (made with chronoconnectivity) where I display the table "question", I would like to filter records by two dropdownlist connected by category and subcategory.
thanks a lot for taking the time and excuse translation errors
simelas 09 Feb, 2017
Hi rluongo,

can you please explain what you mean by "script works in part " . do you get the drop down list ? or not , does it filter or not? etc ....

best rgds

s
rluongo 10 Feb, 2017
hello and thank you for your patience ...
I get the drop down list for a field but selecting an item in the table is not filtered. (for my project I have to filter through two drop-down lists on two fields "category and sub-category")
thank you so much
simelas 11 Feb, 2017
Hi rluongo,

did you put the field [YOURMODEL][YourFieldName] to filter in Setting >>> Filters ?

best

s
Max_admin 12 Feb, 2017
Hi,

Another route would be to use Connectivity v6, add a fields view inside a form view and place that above the table, the "read data" function conditions will need to include the dropdowns names to do the filtering.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Andresvwt 18 Aug, 2017
Great Post. Definitely with this one I got the dropdown filter running. I only would ad for those with so little experience like me, to not forget to add to the code a submit button, i.e.:

<input type="submit" name="submit" value="Filter" />


And in the filter box it should look like:
YOURMODEL.YourFieldName

Thank you all for the help.
This topic is locked and no more replies can be posted.