This content has been marked as final. Show 3 replies
If you are not going to do anything with the data besides displaying it in the data grid then you would be fine to use the slimmer code. However to use the data for anything else, or to be more scalable in the future, you would be better to use the script block as it would allow you to manipulate the data or to make it available to other components.
In mxml files for components that are added to your application mxml file, the script block can define much of the functionallity the component provides and / or needs. The script block can be used in the application mxml file for initialization and massaging the initial state of the application and its data.
The question is not really about the script block, it is about binding directly to lastResult vs using a result handler.
As Garth says if you do not need to do anyting with the data before you display it, then direct binding is ok. But such a situation is rare. Before you know it you will be asking something like, "I need to set my datagrid to the same row it was on before I refreshed my data"... anything like this will require a result handler.
Furthermore, since your DG clearly worked, you were lucky. but what if it did not display correctly the first time you tried it? Direct binding is very hard to debug, since you can't get "between" it an the dg display. Using a result handler, you can inspect/debug the result data in order to craft the dataProvider declaration you want.
I advise getting into the habit of using a result handler. It will pay off in the long run, if there is a long run for you.