This content has been marked as final. Show 12 replies
Any ideas from anyone? I'm stuck on this. As can be seen from the above code, I'm trying to select item 10 from the data grid list, but it won't work.
In datagrid the index start from 0. If you want to keep select the 10th element then you will have to provide th (10-1)th element number.
you can try this one.
Thanks ajeetshama. Unfortunately it doesn't seem to matter what element I assign to the selected index, it still doesn't work. No row is selected, and no scrolling down to a selected row. Am I missing something possibly?
After some further investigation, it appears that there is nothing wrong with the way that I am trying to select the row in my datagrid. The problem is emanating from the fact that I am remotely extracting data from my server using AMFPHP to populate my datagrid. I try and select the row I want after I've made the call to the AMFPHP gateway, but it takes a while for the data to populate the datagrid. Therefore, when I set selectedIndex, the data still doesn't exist in the datagrid.
Any suggestions on how I can force the program to wait for completion of the gateway call (actually the onResult function in the below code) before setting selectedIndex?
use the callLater(functionname,params) function at the end of the function where you make the service call.In that function(functionname()) write the code you want for selecting the index and other things.
Using callLater doesn't seem to help in this situation. The function in callLater still goes off and does it's thing before the onResult function has completed. Is there anyway I can check that the onResult function has finished before setting the selectedIndex property on the datagrid?
Did u check it?..because i thought calllater works that way.i havent checked it though.
flex2008, I agree, it appears that callLater should work the way that you describe, but when I tried it by placing it after the call to the gateway, it didn't work. I don't know why it didn't.
Actually you should place the place the calllater call in your resulthandler method.
Something like this:
/* your code goes here*/
Yes, setting the selectedIndex property from within the result handler function (onResult in my case) does work, however I was hoping to avoid doing that, instead being able set it elsewhere. It appears that this is not the case, so I guess I'll live with it.
"john__p" <email@example.com> wrote in message
> Yes, setting the selectedIndex property from within the result handler
> (onResult in my case) does work, however I was hoping to avoid doing that,
> instead being able set it elsewhere. It appears that this is not the
> case, so
> I guess I'll live with it.
There's an example of how to do this properly here
Thanks Amy, I shall check out the link.