Search Default Value "Between"

Hi. I’m making a Grid with Search and Subtotals… I need the user to define “Between dates” and I succesfully made so… BUT normally they set “the first of the month” and “the last day of the month”… so It would be nice If somehow I can define the value of the Search by default.

I thought in events-onScriptInit referencing the fields, but I realized that is “Between”, so… how I reference the 2 values???

PD: I think that modifyng the SQL would be very difficult to sustain… but I’m open to listen solutions

Thanks again!

Hello my friend, commonly what’s gonna happend is that you can use something like this in the onscriptinit event of your search.


{Date} ='2016-01-01';
$date_input_2_dia = '01'; 
$date_input_2_mes = '01';
$date_input_2_ano = '2016';

in this case my field’s name is Date…

Hope this works for you, I can explain why but this is gonna make a HUUUUUGE POST. and I’m in my mobile.

Regards

I don’t understand your example… How is that solving my problem??? The parameters are BETWEEN dates… so how I would define the 2 dates???

Well it is quite simple:

in your onscriptinit event of the search option you assign the {Date} field to the required date…

{Date} = '2016-01-01' 

But if you leave it like that only one of the 2 date inputs will be set. the second part

$date_input_2_dia = '01'; 
$date_input_2_mes = '01';
$date_input_2_ano = '2016'; 

Sets the second Date fields for the search in this case i set both to the same date but you can set the latest to the end of the month if you want.

Does that explains it?.

Regards

Hi ariwais

If you want to use a field in the in-built SC searches and filters, my experience is that you have to include it in the SQL. It’s sometimes a bit of a nuisance but it does work.

However, I’d be very happy to change my opinion if someone on the forum has a way to make calculated fields work in the search?
:o)

Best regards, Jeff

Ok. First of all, it works like a charm! Thank you a lot.

Second… it’s the least intuitive thing I would imagine… I mean, if it was {Date_input2} or something like that…

Buy, yes. It works. Thanks!

oh man what can I say… wellcome to the magic world of code generatos >.<… scriptcase is not perfect yet but… If you know your way around it you can work miracles… keep it up with your projects and whenever you find something useful share it with the community we’ll all appreciate it.

Glad it worked.

Regards