Jump to content

How can i get visual range of UniStringGrid?


rgreat

Recommended Posts

Hi,

 

it's a first draft:

function beforeInit(sender, config)
{
    var me = sender;

    me._getFirstVisibleRow = function() {

        i = 0;
        me.store.each(function(rec) {
            ss = Ext.fly(me.normalGrid.view.getNode(rec, true));
            sd = ss.getTop() - (me.el.getTop() + me.normalGrid.getHeaderContainer().getHeight() - (ss.getHeight() / 2));

            if (sd < 0) {
                i += 1;
            } else {
                return false;
            }
        });

        return i;
    };

    me._getLastVisibleRow = function() {

        i = 0;
        me.store.each(function(rec) {
            ss = Ext.fly(me.normalGrid.view.getNode(rec, true));
            sd = ss.getTop() - (me.el.getTop() + me.normalGrid.getHeaderContainer().getHeight() - (ss.getHeight() / 2));

            if (sd < me.normalGrid.view.el.getHeight()) {
                i += 1;
            } else {
                return false;
            }
        });

        return i;
    };
}

Best regards,

Link to comment
Share on other sites

Handing rowModel.select:

function rowModel.select(sender, record, index, eOpts)
{
  alert(sender.grid._getFirstVisibleRow()+' '+sender.grid._getLastVisibleRow());
}

Working while TopRow = 0

 

then i scroll grid down, so TopRow > 0 

ss = Ext.fly(me.view.getNode(rec, true)); 

ss = null so 

ss.getTop()

 raises an error.

Link to comment
Share on other sites

Sorry for delay, but StringGrid shows very inconstant behaviour.

 

It must give alert with TopRow/BottomRow values on cell selection change.

 

Just try to browse the grid (top and bottom parts) and you will see. 

Also test buttons will give errors if clicked in sequence.

 

If i use BeginUpdate/EndUpdate in InitGrid function (see example) it glitches a bit different but still glitched.

 

 

sgtest.zip

Link to comment
Share on other sites

Hi,

 

Also you can try to use this approach (maybe you need to optimize and adjust to some extent):

function select(sender, record, index, eOpts)
{
    //alert('Top: '+sender.grid._getFirstVisibleRow()+', Bottom: '+sender.grid._getLastVisibleRow());

    firstRowIndex = 0;
    lastRowIndex = 0;
    
    var me=sender.grid;
    startIndex = me.view.all.startIndex;
    endIndex = me.view.all.endIndex;
    
    for (i = startIndex; i < endIndex; i++) {
        if ((Ext.get(me.view.getRow(i)).getTop() - me.headerCt.getHeight() - Ext.get(me.view.getRow(i)).getHeight()) >= 0) {
            firstRowIndex = i;
            break;
        };
    };

    for (i = startIndex; i < endIndex; i++) {
        if ((Ext.get(me.view.getRow(i)).getTop() - me.headerCt.getHeight()) > me.view.getHeight()) {
            lastRowIndex = i;
            break;
        };
    };
    
    alert('Top: '+firstRowIndex+', Bottom: '+lastRowIndex);
}

Best regards,

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...