Help required, Filtering between two dates

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
tjoseph
Posts: 2
Joined: 2019-11-25 12:25

Help required, Filtering between two dates

Post by tjoseph » 2019-11-27 20:39

Please help. I am a newbie to programming and Appgini has really helped me with my learning curve. This time I need a help for the below code. Basically I am trying to create a dedicated button for custom filter. Somehow the below code dosen't work for "AND" function. The code is used in table_name-tv.js


$j(function() {

var someDate = new Date();
var numberOfDaysToAdd = 7;
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);

var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();

var newdate = dd + '-'+ mm + '-'+ y;


var someDate1 = new Date();

var dd1 = someDate1.getDate();
var mm1 = someDate1.getMonth() + 1;
var y1 = someDate1.getFullYear();

var currentdate = dd1 + '-'+ mm1 + '-'+ y1;

var filter = {
'FilterField[1]': 9, // change this to the actual index of your date field
'FilterOperator[1]': 'less-than-or-equal-to',
'FilterValue[1]': newdate
'FilterAnd[1]': 'and',
'FilterField[2]': 9, // change this to the actual index of your date field
'FilterOperator[2]': 'greater-than-or-equal-to',
'FilterValue[2]': currentdate
};

var url = 'table_name_view.php?SortField=9&SortDirection=asc&' + $j.param(filter);

$j('<a class="btn btn-lg btn-default btn-danger" href="' + url + '"><i class="glyphicon glyphicon-hourglass"></i>Test 1 Week</a>').prependTo('#top_buttons');
})

tjoseph
Posts: 2
Joined: 2019-11-25 12:25

Re: Help required, Filtering between two dates

Post by tjoseph » 2019-11-28 05:23

Solved

I was missing a comma "," in the line

'FilterValue[1]': newdate


All credit goes to Mr. Uday who was very kind to help me

Post Reply