[CLOSED] How to scroll to selected row

  1. #1

    [CLOSED] How to scroll to selected row

    Hi,

    Is there a way to scroll to the selected (i.e.RowSelectionModel) row of a GrdiPanel on load ?


    -tansu
  2. #2

    RE: [CLOSED] How to scroll to selected row

    Hi,

    There is focusRow function in GridPanel's View. It is ensure visible for row
    grid.getView().focusRow(numberOfRow);
    *
  3. #3

    RE: [CLOSED] How to scroll to selected row

    Hi Vladsch,

    I get "Microsoft JScript runtime error: 'this.getRow(...)' is null or not an object" at

    Ext.grid.GridView.override({
        getCell: function (row, col) {
            var tds = this.getRow(row).getElementsByTagName("td");
            var ind = -1;
            for (var i = 0; i < tds.length; i++) {
                if (Ext.fly(tds[i]).hasClass("x-grid3-col x-grid3-cell")) {
                    ind++;
                    if (ind == col) {
                        return tds[i];
                    }
                }
            }
        }
    });
    because row is Nan. Code is below:

    store.DataSource = ds;
    store.DataBind();
    RowSelectionModel model = (grid.SelectionModel.Primary as RowSelectionModel);
                    model.SelectedRows.Add(new SelectedRow(selected.ToString()));
                    model.UpdateSelection();
                    Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current).AddScript(string.Format("Ext.getCmp('{0}').getView().focusRow({1});", grid.ClientID, selected.RowIndex));
    Rowselection is done but grid cannot scroll. selected.RowIndex returns the position of the entity in data source.

    What may be the reason ?
  4. #4

    RE: [CLOSED] How to scroll to selected row

    http://extjs.com/forum/showthread.php?t=64016 . I tried, I set GridPanel.DeferRowRender to false but same result.
  5. #5

    RE: [CLOSED] How to scroll to selected row

    Hi,

    Script of ScriptManager executes early then script of selection model. Try use AddScript of RowSelectionModel instead ScriptManager


    sm.AddScript("Ext.getCmp('{0}').getView().focusRow({1});", grid.ClientID, selected.RowIndex);
    *
  6. #6

    RE: [CLOSED] How to scroll to selected row

    hmm. It worked now. Vladsch, is there a documentation on when to use use ScriptManager and coolite controls AddScript methods ? Or can you explain the difference and using Control.AddScript ?

    -tansu
  7. #7

    RE: [CLOSED] How to scroll to selected row

    Hi,

    At this moment the script sequence depends from control position in page hierarchy. So, the earlier component is placed on the page, the earlier start of the script


    We are planning to change it and to save script sequence as user register/call it on server. It is quite important for us and we will try implement it ASAP
  8. #8

    RE: [CLOSED] How to scroll to selected row

    Yes, it is very important because I can find every method or property but I always waste time with correcting errors.

    Thanks.
  9. #9

    RE: [CLOSED] How to scroll to selected row

    We've made some revisions to the sequencing of the scripts. You should no longer require the .AddScript work-around.

    New code has been committed to SVN, although we are still running some tests.*


    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] TreePanel scrollbar does not scroll to selected node
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Feb 09, 2012, 11:30 AM
  2. Replies: 1
    Last Post: Nov 17, 2010, 12:42 PM
  3. Replies: 1
    Last Post: Oct 13, 2010, 11:09 PM
  4. Replies: 3
    Last Post: Aug 21, 2010, 5:26 AM
  5. Replies: 2
    Last Post: Dec 25, 2009, 2:56 PM

Posting Permissions