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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

FlexCoders mailing list
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();
 

 }
 
Reply | Threaded
Open this post in threaded view
|

Re: flex multiple filter function using text input, combobox and date range

FlexCoders mailing list
any help?
Reply | Threaded
Open this post in threaded view
|

Re: flex multiple filter function using text input, combobox and date range

FlexCoders mailing list
Help with what?

      From: "[hidden email] [flexcoders]" <[hidden email]>
 To: [hidden email]
 Sent: Thursday, December 3, 2015 9:31 AM
 Subject: [flexcoders] Re: flex multiple filter function using text input, combobox and date range
   
<!--#yiv0091838748 #yiv0091838748 .yiv0091838748ygrp-photo-title{clear:both;font-size:smaller;height:15px;overflow:hidden;text-align:center;width:75px;}#yiv0091838748 div.yiv0091838748ygrp-photo{background-position:center;background-repeat:no-repeat;background-color:white;border:1px solid black;height:62px;width:62px;}#yiv0091838748 div.yiv0091838748photo-title a, #yiv0091838748 div.yiv0091838748photo-title a:active, #yiv0091838748 div.yiv0091838748photo-title a:hover, #yiv0091838748 div.yiv0091838748photo-title a:visited {text-decoration:none;}#yiv0091838748 div.yiv0091838748attach-table div.yiv0091838748attach-row {clear:both;}#yiv0091838748 div.yiv0091838748attach-table div.yiv0091838748attach-row div {float:left;}#yiv0091838748 p {clear:both;padding:15px 0 3px 0;overflow:hidden;}#yiv0091838748 div.yiv0091838748ygrp-file {width:30px;}#yiv0091838748 div.yiv0091838748attach-table div.yiv0091838748attach-row div div a {text-decoration:none;}#yiv0091838748 div.yiv0091838748attach-table div.yiv0091838748attach-row div div span {font-weight:normal;}#yiv0091838748 div.yiv0091838748ygrp-file-title {font-weight:bold;}#yiv0091838748 --> <!--#yiv0091838748 #yiv0091838748ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv0091838748 #yiv0091838748ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv0091838748 #yiv0091838748ygrp-mkp #yiv0091838748hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv0091838748 #yiv0091838748ygrp-mkp #yiv0091838748ads {margin-bottom:10px;}#yiv0091838748 #yiv0091838748ygrp-mkp .yiv0091838748ad {padding:0 0;}#yiv0091838748 #yiv0091838748ygrp-mkp .yiv0091838748ad p {margin:0;}#yiv0091838748 #yiv0091838748ygrp-mkp .yiv0091838748ad a {color:#0000ff;text-decoration:none;}-->

any help?



 
Reply | Threaded
Open this post in threaded view
|

Re: flex multiple filter function using text input, combobox and date range

FlexCoders mailing list
Guidance on how to add a date range filter
Reply | Threaded
Open this post in threaded view
|

Re: flex multiple filter function using text input, combobox and date range

FlexCoders mailing list
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;
            }

 

 

Reply | Threaded
Open this post in threaded view
|

Re: flex multiple filter function using text input, combobox and date range

FlexCoders mailing list
Please Some one help me