[flexcoders] flex multiple filter function using text input, combobox and date range

1 view
Skip to first unread message

stinasius@yahoo.com [flexcoders]

unread,
Dec 3, 2015, 8:29:46 AM12/3/15
to flexc...@yahoogroups.com
 

Hello Guys, i have used multiple filter functions before but i have never used one that involves a date range. I have an arraycollection with items (title, entity and signature_date). i would like to filter the results of the array collection based on those 3 fields of data. 


i want to have it in such a way that signature_date is filtered based on date range, so on my UI i have a text input (id= titleSearch), combobox(entitySearch) and 2 data fields (sDate and eDate).


I can do a filter based on the text input and combobox, but i don't know how to apply the date fields in the filter function. 


Can some please help guide me on this. Below is sample code


/************* start filtering ***********************/

private var docTitle:String="title";

private var selectedEntity:String="--- SELECT ENTITY ---";


private function filterGrid():void

{

collectionAr.filterFunction=myFilterFunction;

collectionAr.refresh();

}


private function myFilterFunction(item:Object):Boolean

{

return (item[docTitle].match(new RegExp(titleSearch.text, 'i'))) && (item.entity == selectedEntity || selectedEntity == "--- SELECT ENTITY ---");

}


private function titleChangeHandler(event:Event):void

{

if (titleSearch.text != '')

{

filterGrid();

}

else

{

filterReset()

}


docs.selectedIndex=0;

}


private function entityChangeHandler(event:Event):void

{

if (entitySearch.selectedItem != null)

selectedEntity=entitySearch.selectedLabel;

filterGrid();

docs.selectedIndex=0;

}


private function filterReset():void

{


collectionAr.filterFunction=null;

collectionAr.refresh();


 

__._,_.___

Posted by: stin...@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

.

__,_._,___

stinasius@yahoo.com [flexcoders]

unread,
Dec 3, 2015, 9:31:35 AM12/3/15
to flexc...@yahoogroups.com

Dave Glasser dglasser@pobox.com [flexcoders]

unread,
Dec 3, 2015, 9:39:31 AM12/3/15
to flexc...@yahoogroups.com
 

Help with what?


From: "stin...@yahoo.com [flexcoders]" <flexc...@yahoogroups.com>
To: flexc...@yahoogroups.com
Sent: Thursday, December 3, 2015 9:31 AM
Subject: [flexcoders] Re: flex multiple filter function using text input, combobox and date range



any help?



__._,_.___

Posted by: Dave Glasser <dgla...@pobox.com>
.

__,_._,___

stinasius@yahoo.com [flexcoders]

unread,
Dec 3, 2015, 9:41:44 AM12/3/15
to flexc...@yahoogroups.com

stinasius@yahoo.com [flexcoders]

unread,
Dec 4, 2015, 7:20:35 AM12/4/15
to flexc...@yahoogroups.com
 

i have this date range filter function i had used in one of my projects, and would like to include it in the overall filter function above;


protected function arrColl_filterFunc(item:Object):Boolean
            {
                var cDate:Number=Date.parse(item.hireDate);

                if (!sDate || !eDate)
                {
                    return true;
                }

                if (sDate.selectedDate && eDate.selectedDate)
                {
                    return (sDate.selectedDate.time <= cDate) && (eDate.selectedDate.time >= cDate);
                }
                else if (sDate.selectedDate)
                {
                    return sDate.selectedDate.time <= cDate;
                }
                else if (eDate.selectedDate)
                {
                    return eDate.selectedDate.time >= cDate;
                }
                else
                {
                    return true;
                }

            }

            protected function initDate():void
            {
                sDate.selectedDate=MIN_DATE;
                sDate.selectableRange={rangeStart: MIN_DATE, rangeEnd: MAX_DATE};

                eDate.selectedDate=MAX_DATE;
                eDate.selectableRange=sDate.selectableRange;
            }


__._,_.___

Posted by: stin...@yahoo.com
.

__,_._,___

stinasius@yahoo.com [flexcoders]

unread,
Dec 5, 2015, 1:55:22 AM12/5/15
to flexc...@yahoogroups.com
Reply all
Reply to author
Forward
0 new messages