Results 1 to 9 of 9

Thread: grid panel find next value in grid greater than X

  1. #1
    Sencha User
    Join Date
    Oct 2013
    Posts
    12

    Default grid panel find next value in grid greater than X

    Hi,
    I have a grid panel with buffered renderer switched on, with the store sorted in ascending order using column colX which holds integer values.
    I want to find the next row that has a colX value greater than my selected colX value.

    //sort ASC by colX
    grid.store.sort( [{property: 'colX', direction: 'ASC'}]);
    // I want to find the index of the next row which has colX greater than 3
    matchindex = find('colX', >3); //I don't know how to do this
    //jump to that row.
    grid.view.bufferedRenderer.scrollTo(matchindex, true);

    I have tried to loop though the store but it get's kinda messy to loop though the pages with buffered rendered switched on especially when I sort it.

    Any help would be much appreciated

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    Would it not be better to perform this at the server where you have access to all the data instead the buffered data and the client and then compare the returned records at the client if needed?

  3. #3
    Sencha User
    Join Date
    Oct 2013
    Posts
    12

    Default

    If I find my row in the database on the server side- do I have to go back to the view to find the row in question using that criteria?

    I suppose what I'm saying is- should there be an easy link between the buffered store and the database it's based on.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    In not knowing your requirement and how many records you are trying to manipulate, it would be difficult to say what is the best approach, but yes .. you would have to recycle this at the client.

    I was thinking of filter the data at the server vs trying to find random records on a buffered grid.

  5. #5
    Sencha User
    Join Date
    Oct 2013
    Posts
    12

    Default

    I don't want to filter the data- I want to scroll to a row that has a cell value that is X greater than the selected cell.

    so I don't actually want to change the store- I want to scroll to a row in my existing store.

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    Ok, back to your issue .. is store.find() not working in your code?

  7. #7
    Sencha User
    Join Date
    Oct 2013
    Posts
    12

    Default

    can I use store.find to find a value greater than x?It seems I can only use it to find an exact value.

  8. #8
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    You can always us findBy() and create a function

    Code:
    store.findBy(function(record) {
        if (record.get('colX') > 3) {
            return true;
        }                        
    });

  9. #9
    Sencha User
    Join Date
    Oct 2013
    Posts
    12

    Default

    Thanks Scott for getting back so quick. Do I put this in the store definition and then iterate though the store's records and call this to compare?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •