Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Chicken/egg problem with getRecordIndex

$
0
0
I'd like to have a row visible and selected when a user is presented with a databound ListGrid, without filtering the results and without loading all the results. That is, the user is invited to change the selection from the current selection. How may I do this?

I feel like I'm going in circles! I don't know the row number in the ListGrid until the record has been fetched, but I can't figure out how to fetch the specific record without filtering or loading all the records (i.e. showAllRecords).

Here's the closest I got. In my ListGrid.create, I have this:
Code:

            recordToSelect: null,
            dataArrived: function(start,stop){
              if(this.recordToSelect){
                  this.selectSingleRecord(this.recordToSelect);
                  var idx = this.getRecordIndex(this.recordToSelect);
                  this.scrollToRow(idx);
                  if(idx != -1){
                    this.recordToSelect = null;
                  }
              }
            },

and after my ListGrid has been created, I call this (variable lg is the ListGrid):
Code:

  lg.dataSource.fetchRecord(initialSelect,function (dsResponse, data, dsRequest) {
      lg.recordToSelect = data[0];
      lg.selectSingleRecord(data[0]);
  });


The record I'm trying to select is not included in the ListGrid's initial fetch, so the desired record isn't selectable until the user scrolls down enough (i.e. effectively loading all the data, which is what I was trying to avoid). Is there a way to accomplish this task?

I looked at ListGrid's data attribute. It looks like I could call the "get" method in the ListGrid's ResultSet if I knew its index and that would fetch the appropriate data, but the ResultSet doesn't appear to provide a way of "find"ing the index before "get"ting the data... It's a chicken-and-egg problem.

Basically... I think I need a variant of getRecordIndex/indexOf which goes to the server.

Viewing all articles
Browse latest Browse all 4756

Trending Articles