[flexcoders] Understanding DataGridColumn#sortCompareFunction with composite custom classes

2008-07-21 Thread florian.salihovic
I'm currently working with a custom classes which are composites. I display the 
needed 
data via custom ItemRenderer which extends the mx.controls.Text component. It 
works 
pretty nice and is pretty flexible. But i need to sort my data as well. After 
some researches 
i learned to implement a custom sortCompareFunction. My current implementation 
works 
just like the following in a class subclassing 
mx.controls.dataGridClasses.DataGridColumn:

 /* Begin */

protected function compare(arg1:CustomClass, arg2: 
CustomClass):int {
if (!super.dataField) {
return 0;
}
return 1;
if (arg1.hasOwnProperty(super.dataField) 
arg2.hasOwnProperty(super.dataField)) {
return 
ObjectUtil.stringCompare(arg1[super.dataField].toString(),

arg2[super.dataField].toString(), true);
}
// property is a known property of the custom class
if (arg1.property.hasOwnProperty(super.dataField) 

arg2.property.hasOwnProperty(super.dataField)) {
return 
ObjectUtil.stringCompare(arg1property[super.dataField].toString(),

arg2.property[super.dataField].toString(), true);
} 
return 0;
}

/* End */

But i get the error message:
Error: Find criteria must contain at least one sort field value.

Where do i have to set it?

Any examples of sorting custom object hierachies in DataGrid controls would be 
appreciated.

Best regards!



RE: [flexcoders] Understanding DataGridColumn#sortCompareFunction with composite custom classes

2008-07-21 Thread Alex Harui
If the property identified by the column's dataField doesn't actually
exist, I think that's when you get this error.  A sortCompareFunction on
a column specifies a SortField's compare function.  You can also specify
a custom Sort with a global compareFunction that shouldn't check for the
existence of fields.  You would get the HEADER_RELEASE event, call
preventDefault() and set the collection's Sort accordingly

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of florian.salihovic
Sent: Monday, July 21, 2008 5:11 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Understanding DataGridColumn#sortCompareFunction
with composite custom classes

 

I'm currently working with a custom classes which are composites. I
display the needed 
data via custom ItemRenderer which extends the mx.controls.Text
component. It works 
pretty nice and is pretty flexible. But i need to sort my data as well.
After some researches 
i learned to implement a custom sortCompareFunction. My current
implementation works 
just like the following in a class subclassing 
mx.controls.dataGridClasses.DataGridColumn:

/* Begin */

protected function compare(arg1:CustomClass, arg2: CustomClass):int {
if (!super.dataField) {
return 0;
}
return 1;
if (arg1.hasOwnProperty(super.dataField) 
arg2.hasOwnProperty(super.dataField)) {
return ObjectUtil.stringCompare(arg1[super.dataField].toString(),
arg2[super.dataField].toString(), true);
}
// property is a known property of the custom class
if (arg1.property.hasOwnProperty(super.dataField) 
arg2.property.hasOwnProperty(super.dataField)) {
return 
ObjectUtil.stringCompare(arg1property[super.dataField].toString(),
arg2.property[super.dataField].toString(), true);
} 
return 0;
}

/* End */

But i get the error message:
Error: Find criteria must contain at least one sort field value.

Where do i have to set it?

Any examples of sorting custom object hierachies in DataGrid controls
would be 
appreciated.

Best regards!