Buy Now
Sign in

custom search field in ccv6

teldrive , August 16 2019, 16:27
teldrive 559
August 16 2019, 16:27 #388865
Hi everyone
I have seen issues related to missing field widget on (view tab CCv6) and and custom search button https://www.chronoengine.com/forums/posts/t105003/how-can-i-add-search-or-filter-fields-to-your-connectivity-6-list?keywords=filter%20list without answers
Mi issue may be simple but I didn't find solution yet:
I need set a dropdown field(qith dynamic key-value pair that works fine and a button to send "selection" to filter results in {fn:read_fields} I generated button-event but I could not make works filtering model.field :{data:selection}
I tried with "search view-widget" and worked fine, but I need my custom dropdown search field+button
Also I don't know why $this->data['field'] doesn't work in ccv6 to call variables as in cfv6, and for example it will be a workaround to make this relation $this->data['keywords'] =$this->data['selection'] to make it works;
I apreciated also if someone can tell me how can i set a dropdown field and button on same line
Teldrive
teldrive 559
January 03 2020, 21:39 #390547
 1
 Answer
Hi Everyone

CCv6 and CFv6 are much better than v5 but it takes time to learn all the higher possibilities that they offer,

if you have been working with chronoengine the last years you will see the forum is the only free support you will get ,

I want to mention the effort of healyhatman to answer many people, I have learn a lot from him

 but anyway if you spent time (or money) you will find very usefull this framewok,

I have used in the begining as ERP programing but I am currently using it for IOT with spectacular results

Let me share with you some advances about this topic that for sure will help you, anf may be  it can be optimized but what I explain here works

************MY GOAL TO MAKE A DYNAMIC DROPDOWN TO FILTER RESULTS IN CCV6*****************

----------------------FIRST STEP: GENERATE AN ARRAY(KEY/VALUE) FROM A DATABASE

create a database function :

name= read_sensores, model =sensor, database=xxxxxx, select type ="return array key/value pairs ......", field to retrieve = field1 field2 ( on diferent line and order is important because first is the key)

---------------------SECOND STEP:CREATE AND ACTION FORM, without this your search field won't work, you can check html code of a view-widget-search as example of inspiration;-)

you will see that view-fields-group doesn't exist anymore, the reason is that can be easily replaced by individual view-fields-elements

create a form area(it will be your action form) name=filter you can add to this two elements: dropdown adn button, but you can add also two search field if you need it

so in content={view:dropdown}{view:boton} ( on different line) also if you want a professional aspect set class=ui action input fluid
Captura1.JPG
---------------------THIRD STEP:CREATE DYNAMIC DROPDOWN with view-fields-dropdown
name=dropdown, name(ofvariable)=sensor_sel, ID=sensor_sel , options = (space)=None {var:read_sensores} (on different line, first one is to reset search)
(take note of the name of function of first step), this will load automatically the key/values on your filter field
you need now
---------------------FOURTH STEP:CREATE BUTTON from view-fields-button( are not valid other types)
name=boton, type=submit, content=filtrar, name(of variable)=filtra,ID=filtra
---------------------FIFTH STEP:ADD TO INDEX EVENT you have a table_view_list if not you can download an example in ccv6-demos
you have defined
{fn:read_fields}(generic database for example)
you only need to add
{fn:read_sensores}(for dynamic dropdown)
{view:filter}(name of second STEP to see filter field on ccv6 form)
you also will have a line like
{view:table_view_list} (that shows you the data rows)
---------------------SIXTH STEP:ADD FILTER TO FUNCTION THAT USE YOUR table_view_list you have a table_view_list if not you can download an example in ccv6-demos
you only have to add to the function{fn:read_fields} a condition
field1(to filter) LIKE {data:sensor_sel}% (related to name of dropdown defined on stepTHREE), have in mind that % is the wildcard for this method of filtering
have also in mind that field1 is the field that you have chosen as key parameter
That's all folk , have fun with CC&CF
Attachments
Captura1.JPG
Captura1.JPG
(23.26 KiB)
246 Downloads/Views
Teldrive
C
cruser 49
March 26 2020, 19:30 #391782
Do you have this in an example form?
J
joaoparao 20
April 09 2020, 20:27 #391951
Hi teldrive,
excellent tutorial: i solved most of my problem.
But now I have a problem with the paginator: the first search works correctly, when I select the next block it doesn't keep the search in memory.
Do you have any suggestions to solve the problem?
Thanks a lot
Joao