That would make sense, but I'm actually seeing something else. Thanks 
in advance for any help with this!  

I put in trace statements in all the methods of my dataProvider and 
the output below is what I get when a simple app with a DataGrid 
starts up.  The Constructor is called, the getItemAt() with an index 
of 'undefined', then get length() is called a bunch of times and 
returns 5 each time, then getItemAt(0), etc, etc.

(The code for the getItemAt method follows the trace.)

[Debug] DPTest initialized
[Debug] TestDP(undefined)
[Debug] getItemAt(undefined)
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] getItemAt(0)
[Debug] getItemAt(1)
[Debug] getItemAt(2)
[Debug] getItemAt(3)
[Debug] getItemAt(4)
[Debug] getItemAt(5)
[Debug] getItemAt(6)
[Debug] getItemAt(7)
[Debug] getItemAt(8)
[Debug] getItemAt(9)
[Debug] getItemAt(10)
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5
[Debug] get length():5


Here's the actual code of my dataProvider.getItemAt method.  The 
DataGrid displays the Names from "0 - .." to "4 - ..", skipping 
the "Undefined 1234" name.

(Note: the reason for writing this method like this is to try and 
understand the interaction between the dataProvider and its users.)

        function getItemAt(index : Number)
        {
                Echo.debug('getItemAt(' + index + ')');
                if(index==undefined){
                        var o:Object = new Object();
                        o.Name = "Undefined 1234";
                        return o;
                } else if(index==0){
                        var o:Object = new Object();
                        o.Name = "0 - 1234";
                        return o;
                } else if(index==1){
                        var o:Object = new Object();
                        o.Name = "1 - 1234";
                        return o;
                } else if(index==2){
                        var o:Object = new Object();
                        o.Name = "2 - 1234";
                        return o;
                } else if(index==3){
                        var o:Object = new Object();
                        o.Name = "3 - 1234";
                        return o;
                } else if(index==4){
                        var o:Object = new Object();
                        o.Name = "4 - 1234";
                        return o;
                } else {
                        return null;
                }
        }
--- In [email protected], "Matt Chotin" <[EMAIL PROTECTED]> wrote:
> I'd imagine that if you're seeing numerous calls to length 
interspersed
> with getItemAt that we simply didn't do an optimal loop.
> 
>  
> 
> for (var idx = 0; idx < dataProvider.length; ++idx)
> 
> {
> 
>   var item = getItemAt(idx);
> 
> }
> 
>  
> 
> get length() is going to be called on every iteration of the loop.  
It'd
> obviously be more efficient to store length in a local variable and 
just
> use that, but maybe we didn't somewhere.
> 
>  
> 
> Matt
> 
> ________________________________
> 
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of rbelknap
> Sent: Friday, June 03, 2005 3:24 PM
> To: [email protected]
> Subject: [flexcoders] Contract between DataProvider and ComboBox or
> DataGrid
> 
>  
> 
> Hi,
> 
> I'm struggling to figure out the implied contract between 
> DataProviders and their users like ComboBox or DataGrid. When 
either 
> a ComboBox or DataGrid first uses a DataProvider they seem to make 
> numerous calls to:
> 
>    public function get length():Number
> 
> and 
> 
>    function getItemAt(index : Number)
> 
> but it isn't obvious what the logic is behind these calls.  
> 
> I was expecting to see a call to get the length followed by a 
series 
> of calls to getItemAt starting at index 0 and running to index 
length-
> 1, but that's not what I see.
> 
> Has anyone run across any good discussions of DataProviders and 
their 
> users?
> 
> Thanks,
> 
> Randy
> 
> 
> 
> 
> 
> 
> ________________________________
> 
> Yahoo! Groups Links
> 
> *     To visit your group on the web, go to:
>       http://groups.yahoo.com/group/flexcoders/
>         
> *     To unsubscribe from this group, send an email to:
>       [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> 
>         
> *     Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to