1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    4
    Vote Rating
    0
    Rasmus is on a distinguished road

      0  

    Default New grid event model

    New grid event model


    I am sure I am missing something obvious here, but I can't get the new events to behave. Simplifying it a bit, I have something like this:
    Code:
        this.selectRow = function(grid, rowIndex, colIndex, e){
           console.log(rowIndex);
           console.log(e);
        }
        this.selModel = new YAHOO.ext.grid.SingleSelectionModel();
    
        this.grid = new YAHOO.ext.grid.Grid('grid', this.dataModel, this.colModel, this.selModel);
        this.grid.autoSizeColumns = true;
        this.grid.minColumnWidth = 5;
        this.grid.maxRowsToMeasure = 5;
        this.grid.render();
        this.selModel.selectFirstRow();
        Grid.dataModel.load(...);
        this.selModel.addListener('rowselect', this.selectRow, this.grid, true);
    In my selectRow function, e is always undefined, and instead of a useful rowIndex I am getting a span element:
    Code:
    span class="ygrid-row ygrid-row-selected" style="top: 84px;"

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    The event handler signature (from DefaultSelectionModel docs):
    Fires when a row is selected or deselected - fireDirect sig: (this, row, isSelected)

    Row is the actual HTML row object. The row index is available as row.rowIndex. isSelected is a boolean value of whether or not the row was selected or deselected.

    So your code would look like this:
    Code:
    this.selectRow = function(grid, row, isSelected){
           console.log(row.rowIndex);
           console.log(isSelected);
        }
    I would have liked to update these signatures to match the rowIndex and e provided by the grid's events rather than the raw row object, but I didn't want to break any existing code.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    4
    Vote Rating
    0
    Rasmus is on a distinguished road

      0  

    Default


    Aha. By the way, I noticed in your forum2 UI, the last line of my initial post in this thread isn't visible while in the normal UI you can see it.

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Thanks for pointing that out, I missed it. My regular expression was being greedy and matching both code blocks as one. I've fixed it.

    Jack

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    36
    Vote Rating
    0
    kovtik is on a distinguished road

      0  

    Default


    Look at the following code:
    Code:
    <head id="Head1" runat="server">
        <title>Grid</title>
        <link href="css/grid.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="js/yui/yahoo.js"></script>
        <script type="text/javascript" src="js/yui/event.js"></script>
        <script type="text/javascript" src="js/yui/dom.js"></script>
        <script type="text/javascript" src="js/yui/dragdrop.js"></script>
        <script type="text/javascript" src="js/yui/animation.js"></script>
        <script type="text/javascript" src="js/yui/connection.js"></script>
        <script type="text/javascript" src="js/yui-ext/yui-ext.js"></script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="grid" style="width:630px;height:500px;overflow:hidden;position:relative;"></div>  
    <script type="text/javascript">
    var Example = {
        init : function(){
            var data = [["name1","type1"],["name2","type2"]];
            var dataModel = new YAHOO.ext.grid.DefaultDataModel(data);
    
            var myColumns = [
                {header: "Name", width: 200},
                {header: "Type", width: 100}
            ];
    
            var colModel = new YAHOO.ext.grid.DefaultColumnModel(myColumns);
            
            this.grid = new YAHOO.ext.grid.Grid('grid', dataModel, colModel);
    
            this.grid.render();
            
            var onRowDoubleClick = function(grid, rowIndex, e){ alert(); }
    
            var selModel = this.grid.getSelectionModel();
            selModel.addListener('rowdblclick', onRowDoubleClick); 
        }
    }
    YAHOO.util.Event.on(window, 'load', Example.init, Example, true);
    </script>
        </form>
    </body>
    </html>
    When running this code I recieve the following error: 'this.events[...]' is null or not an object. Could you also explain me why I recieve another error ('DefaultSelectionModel' is undefined) if I write
    Code:
    var onRowDoubleClick = function(grid, rowIndex, e){ alert(); }
    
    var selModel = this.grid.getSelectionModel();
    selModel.addListener('rowdblclick', onRowDoubleClick);
    before
    Code:
    this.grid.render();
    Should I explicitly create YAHOO.ext.grid.DefaultSelectionModel object and pass it to the grid constructor or this object is created during the creation of the grid?

  6. #6
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    rowdblclick is a grid event, not a selection model event. The event is undefined on selModel which is why it throws the undefined error. Try this:

    Code:
    this.grid.addListener('rowdblclick', onRowDoubleClick);
    Could you also explain me why I recieve another error ('DefaultSelectionModel' is undefined) if I write...

    If no selection model exists when render() is called, it creates a DefaultSelectionModel. That's why calling getSelectionModel() after render() results in a selection model even though you didn't provide one. If you need access to the selection model before render(), you will need to create it and pass it to the constructor when creating your grid.

  7. #7
    Ext User
    Join Date
    Mar 2007
    Posts
    36
    Vote Rating
    0
    kovtik is on a distinguished road

      0  

    Default


    rowdblclick is a grid event, not a selection model event...
    Thank you for your help.

Similar Threads

  1. JSON Data Model?
    By cobnet in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 1 Mar 2007, 1:16 AM
  2. get the data model from a jsonview?
    By jbowman in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 4 Dec 2006, 6:22 AM
  3. Grid Editor and Selection Model
    By jack.slocum in forum Community Discussion
    Replies: 0
    Last Post: 10 Nov 2006, 3:49 AM
  4. Duplicating the Box Model Bug
    By gknitz in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 8 Nov 2006, 9:00 PM
  5. Can a rendered grid receive a new data model?
    By christocracy in forum Ext 1.x: Help & Discussion
    Replies: 22
    Last Post: 18 Oct 2006, 4:30 PM

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi