1 Reply Latest reply on Apr 11, 2012 11:34 AM by Zolotoj

    Help with createPendingItemFunction

    Zolotoj Level 3

      I have a datagrid with paging functionality. Everything works as long as I scroll somewhat slow. But if I scroll very fast ot better yet select first row and then press end it crashes. The error is coming out of the following code:

      public function setItemAt(item:Object, index:int):Object

          {

              if (index < 0 || index >= length)

              {

                  var message:String = resourceManager.getString(

                      "collections", "outOfBounds", [ index ]);

                  throw new RangeError(message);

              }

      ....

      which is an SDK code.

       

      I can manage to not to get an error but then I see that a hlaf on the grids has blank rows.

       

      Any idea what to do?

       

      Thanks

        • 1. Re: Help with createPendingItemFunction
          Zolotoj Level 3

          Here is my code:

          public function handleCreatePendingItemFunction(index:int, ipe:ItemPendingError):Object

                              {

                                        numItemsToFetch = pageSize;

                                        var page:uint=Math.floor(index / pageSize);

                                        if (fetchedPages[page] == undefined)

                                        {

                                                  startIndex=pageSize * page;

                                                  var endIndex:uint=startIndex + pageSize - 1;

                                                  if (endIndex > list.length)

                                                  {

                                                            numItemsToFetch=list.length - startIndex;

                                                  }

                                                  var request:PagedDataRequest = new PagedDataRequestFactory().getPagedDataRequest(startIndex, numItemsToFetch, null, null, request);

                                                  callService();

                                                  fetchedPages[page]=true;

                                        }

                                        return null;

                              }

          What happens is when a user is scrolling very fast this code gets executed for more than one page. As a result startIndex is not correct and the grid has blank rows.