Question : Error: Find criteria must contain at least one sort field value. DataGridColum

I am getting the following error and I know what is causing it but I am confused as to how to resolve it.

"Error: Find criteria must contain at least one sort field value."

It occurs when I click on a column in my DataGrid so that I can sort by that column. The Sort.as class looks up the DataField (in this case 'rolledUpTotal') and finds that the DataField does not exist in the datasource and hence throws the error. The reasons the column is not in the dataSource is because it is derived from two other fields in the dataSource object as follows .

So rolledUpTotal  is derived from the 'chargeIncludingTax' minus 'tax' fields. I dont want to go changing the persistant object to add in a new field which would make it work.

My datasource is an Array of Persistant (Model) Objects retrieved from the database. And the class looks as follows (simplified for clarity)

package com.test.model
{
      import com.test.model.Persistent;
      
      [Bindable]
      [RemoteClass(alias="com.test.model.InvoiceLine")]
      public class InvoiceLine extends Persistent
      {
      
         public var originalLineNumber: String;         
          
           public var chargeIncludingTax: Number;
           public va tax: Number;
     }
}

The DataSet column looks like this.

<mx:DataGridColumn  dataField="rolledUpTotal" headerText="SomeText"/>


I think there is a way to do this using the sortCompareFunction but having messed about with ti I cannot get it to work.

Anyone any suggestions ?

Thanks


Answer : Error: Find criteria must contain at least one sort field value. DataGridColum

Well I think I may have resolved this myself.

I put in a sortCompareFunction called from DataGridColumn and then I put in a dummy field into the Model class. So when the Sort.as still went and checked the dataField it found the field and did not spit out the error. Directly after that the sortCompareFunction then gets called and does the actual sort. Not very pretty but it seems to work now.
Random Solutions  
 
programming4us programming4us