1 Reply Latest reply on Apr 23, 2009 8:19 AM by EvolvedDSM

    FilterFunction causing mis-read Date data-type in DG

    EvolvedDSM Level 2

      I have a datagrid that displays data from an arrayCollection.  The arrayCollection is populated from a remoteObject call to query a db table.  I have form fields that are bound to the selectedItem values of the datagrid so i can edit entries within the form and then submit my changes.  This works fine.


      Because the number of results in the datagrid can be hundreds, I added a filterfunction search box.  The filterFunction works fine as I can type in anything and it finds the correct records every time.  Clicking on the datagrid record after the filterfunction has filtered the data, the data appears to be properly bound to my form fields.  However, upon submitting new changes, the date field seems to be capturing a NULL value (1/0/NaN is what it takes on).  Of course, when I look at the date form field, it displays the actual date from the datagrid.  So I'm not sure how it's resulting in a NULL value when I submit the data.  All the other data stays persistent on my submission while under filterFunction.


      I've tried using both a dateField input as well as a textInput to capture the date and both of them are submitting a NULL value to my valueObject even though the field itself displays the date.  And as said, if I choose not to filterFunction my datagrid data, the update succeeds without an issue.  It's only after my data gets run through the filterFunction that the date becomes submitted as a NULL value.


      filter Code:


      The search criteria text input for the filter:

      <mx:TextInput id="histTextFilter" change="filterHistory()" color="#000000"/>


           private function filterHistory():void{
              ac.filterFunction = histFilter;
          // Filters DG
          private function histFilter(obj:Object):Boolean{
              var isMatch:Boolean = false
              if(obj.clientName.toLowerCase().search(histTextFilter.text.toLowerCase()) != -1){
                  isMatch = true;
              return isMatch;
          // Clears the filter
          private function resetSearchFilter():void{
              histTextFilter.text = '';
              ac.filterFunction = null;


      Update Code:

      <mx:Button label="Update" click="updateHistory()" id="updateBtn"/>

                private function updateHistory():void{
                          upObj = new editHist; // editHist is a valueObject
                          upObj = histDG.selectedItem as editHist; // sets VO to datagrid's selectedItem
                          upObj.firstName = firstNameInput.text;
                          upObj.lastName = lastNameInput.text;
                          upObj.message = messageInput.text;
                          var getDate:Date = new Date(theDateInput.text); // theDateInput is the field that holds the date value of my datagrid data
                          upObj.theDate = getDate;
                          histRO.update(upObj); // remoteObject method to update data


      Everything works fine until the data is filtered.  Then the Date value becomes Null.

        • 1. Re: FilterFunction causing mis-read Date data-type in DG
          EvolvedDSM Level 2

          Note: clientName in the filterFunction method is another datagrid property that combines both firstName and lastName values.  It's only purpose is for the filter.  It's created in my query (Select firstName + ' ' + lastName AS clientName)




          If no changes are made to the form fields (data stays consistent with original data), the update will return the correct date.  However, if any of the form fields are modified and then submitted, it returns "Invalid Date" (this is what Alert.show() outputs).


          Very, very strange.  I'm not sure why editing any of the form fields would have an effect on the date field.