Hi Max,
In Chrono Connectivity v5 is it possible to filter by a range of results, ideally I would like to have a select box for minimum (number) and another select select box for maximum (number) and then return all the results in between?
In Chrono Connectivity v5 is it possible to filter by a range of results, ideally I would like to have a select box for minimum (number) and another select select box for maximum (number) and then return all the results in between?
Hi Edworthy,
Just use this code in your conditions box after you do the necessary adjustments to the Mode, field, min and max:
Regards,
Max
Just use this code in your conditions box after you do the necessary adjustments to the Mode, field, min and max:
return array("Model.field >=" => \GCore\Libs\Request::data("min"), "Model.field <=" => \GCore\Libs\Request::data("max"));
Regards,
Max
Thanks Max,
If I understand this correctly it will filter the results when the connection is made. Is it possible to filter by a range of results after the connection is made?
I would like to show all entries when they first open the connection and then have the option to filter using minimum and maximum select boxes or input boxes similar to fltr[Model][field].
If I understand this correctly it will filter the results when the connection is made. Is it possible to filter by a range of results after the connection is made?
I would like to show all entries when they first open the connection and then have the option to filter using minimum and maximum select boxes or input boxes similar to fltr[Model][field].
Well, Just put the whole code inside an if statement:
if(\GCore\Libs\Request::data("min")){
//return your conditions here
}
Hi Max,
Are you able to give me a short example?
I have my Display type set to Custom.
Do I need to put this:
How would I define the search text inputs for this? Currently they are set in the header as:
Do I also need to add the Model.field I am searching to the Searchable area in the Settings tab?
What would I need to put inside the body code to display the results?
Sorry for all the questions.
Are you able to give me a short example?
I have my Display type set to Custom.
Do I need to put this:
if(\GCore\Libs\Request::data("pricemin")){
return array("Model.field >=" => \GCore\Libs\Request::data("pricemin"), "Model.field <=" => \GCore\Libs\Request::data("pricemax"));
}
inside the Header code area?
How would I define the search text inputs for this? Currently they are set in the header as:
<b>Search:</b><input type="text" name="srch" />
<b>Price Min:</b><input type="text" name="pricemin" />
<b>Price Max:</b><input type="text" name="pricemax" />
<input type="submit" name="submit" value="Search" />
Do I also need to add the Model.field I am searching to the Searchable area in the Settings tab?
What would I need to put inside the body code to display the results?
Sorry for all the questions.
Your fields code should go in the "header" section, and the first code chunk should go in the "Conditions" box under "models", just make sure it has a starting php tag first: <?php
Regards,
Max
Regards,
Max
Thanks Max, it worked.
But now I have run into another challenge, my Model.field is JSON encoded and it has a value for price, eg:
{"landsize":"3700","price":"200000"}
Would there be a way of returning all the results between minimum and maximum values from the JSON encoded data within Model.field ?
Here is a related post that Bob assisted me in getting my JSON encoded data into columns: https://www.chronoengine.com/forums/posts/f12/t99099/splitting-comma-separated-values-field-into-columns.html
But now I have run into another challenge, my Model.field is JSON encoded and it has a value for price, eg:
{"landsize":"3700","price":"200000"}
Would there be a way of returning all the results between minimum and maximum values from the JSON encoded data within Model.field ?
Here is a related post that Bob assisted me in getting my JSON encoded data into columns: https://www.chronoengine.com/forums/posts/f12/t99099/splitting-comma-separated-values-field-into-columns.html
If the value is part of a string (JSON string) inside a field then I have no idea how to make this comparison, you usually use the full field value for comparison.
If you can move all your encoded parameters into a new table (multiple fields) with a foreign key pointing to the main table then you can setup a "hasOne" relation and get it to work.
Regards,
Max
If you can move all your encoded parameters into a new table (multiple fields) with a foreign key pointing to the main table then you can setup a "hasOne" relation and get it to work.
Regards,
Max
Hi Max,
I'm using
to filter by a range of results. However, nothing happens when I fill in the datemin or datemax fields and submit. (The fields code is actually in the footer.) I'm wondering if this has to do with the fact that the field I'm comparing to (view_Docs.DATEIN) is a timestamp in the database. Is there a way to fix this?
Also, in terms of the timestamp in general, I would like to display the column of dates in a different format than the timestamp (e.g. m-d-Y intstead of Y-m-d h:i:s). How do I do that?
Thanks,
AK
I'm using
<?php
if(\GCore\Libs\Request::data("datemin")){
return array("view_Docs.DATEIN >=" => \GCore\Libs\Request::data("datemin");}
if(\GCore\Libs\Request::data("datemax")){
return array("view_Docs.DATEIN <=" => \GCore\Libs\Request::data("datemax"));}
?>
to filter by a range of results. However, nothing happens when I fill in the datemin or datemax fields and submit. (The fields code is actually in the footer.) I'm wondering if this has to do with the fact that the field I'm comparing to (view_Docs.DATEIN) is a timestamp in the database. Is there a way to fix this?
Also, in terms of the timestamp in general, I would like to display the column of dates in a different format than the timestamp (e.g. m-d-Y intstead of Y-m-d h:i:s). How do I do that?
Thanks,
AK
This topic is locked and no more replies can be posted.
