DataGrid error - Find criteria must contain at least one sort field value


I got the above error message while doing some random tests on my current Flex application. This always seemed to be happening under the following scenario… a DataGrid was on the screen, the grid was binded to a collection (myVosArrayCollection). One of the gird columns data fields was pointing to a nested value (myVO.field.child) :

<pre style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); border: 1px dashed rgb(153, 153, 153); line-height: 14px; padding: 5px; overflow: auto; width: 95%;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;"> <mx:DataGridColumn dataProvider="{myVosArrayCollection}" dataField="field.child".../>
</pre>
It seems like Flex has a problem dealing with nested objects for dataGrid column dataField. My solution is adding a wrapper getter on myVO.field.child , for me this is only natural as I’m using a two level VOs hierarchy exactly for these sort of scenarios, the BaseVO and the VO it self (but that’s something I’ll cover on a different post). MyVo now have a new getter:

<pre style="font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; border: 1px dashed rgb(153, 153, 153); line-height: 14px; padding: 5px; overflow: auto; width: 95%;">public class MyVO
{
private var field:Object;

public function get fieldChild():Object
{
return field.child;
}
}
</pre>
my DataGrid now has the following setup:

<pre style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); border: 1px dashed rgb(153, 153, 153); line-height: 14px; padding: 5px; overflow: auto; width: 95%;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;"> <mx:DataGridColumn dataProvider="{myVosArrayCollection}" dataField="fieldChild".../>
</pre>This solved the issue for me.

Developer