Results 1 to 9 of 9

Thread: [SOLVED] DataView selectionchange event doesn't fire

  1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default [SOLVED] DataView selectionchange event doesn't fire

    I'm using DataView and when I select a node, it doesn't fire selectionchange!
    here's the html: http://amcsi.jgypk.hu/layout/dataViewTest.html
    here's the js: http://amcsi.jgypk.hu/layout/script/dataViewTest.js
    here's the code, if you don't want to read the js:
    Code:
    function begin() {
    	Ext.ns('Ext.ux.layout');
    
    	var postFields = [
    		{name: 'contentText', mapping: 'ContentText'},
    	]
    	var postStore = new Ext.data.XmlStore({
    		record: 'Posts Post',
    		totalProperty: 'PostView Posts',
    		fields: postFields,
    		url: 'xml/sample_postview.xml'
    	})
    	postStore.load()
    	var postTpl = new Ext.XTemplate(
    		'<tpl for=".">',
            '<div class="post" id="post_{#}">',
    		 '<span>{contentText}</span>',
            '</div>',
    		'</tpl>'
    	)
    	var dv
    	dv = new Ext.DataView({
    		itemSelector: 'div.post',
    		overClass: 'post-over',
    		autoHeight:true,
    		cls: 'left_box',
    		store: postStore,
    		tpl: postTpl,
    		listeners: {
    			selectionchange: {
    				fn: function (dv, nodes) {
    					alert('it works!')
    				}
    			},
    		}
    	})
    	dv.render(document.body)
    }
    please help

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Which Ext version? I seem to recall a bug that could cause this.

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default

    3.2.1

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    And you don't get any errors?

    ps. Run your code through jslint.com and remove all the warnings.

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default

    Firebug doesn't show any errors
    I made jslint like the code. Still doesn't work :/

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Strange... Can you post the code you have now after fixing the warnings?

  7. #7
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default

    Code:
    /* jslint devel: true */
    function begin() {
        var postFields = [ 
            {name: 'contentText', mapping: 'ContentText'}
        ];  
        var postStore = new Ext.data.XmlStore({
            record: 'Posts Post',
            totalProperty: 'PostView Posts',
            fields: postFields,
            url: 'xml/sample_postview.xml'
        }); 
        postStore.load();
        var postTpl = new Ext.XTemplate(
            '<tpl for=".">',
            '<div class="post" id="post_{#}">',
             '<span>{contentText}</span>',
            '</div>',
            '</tpl>'
        );  
        var dv; 
            dv =    new Ext.DataView({
                                    itemSelector: 'div.post',
                                    overClass: 'post-over',
                                    autoHeight:true,
                                    cls: 'left_box',
                                    store: postStore,
                                    tpl: postTpl,
                                    listeners: {
                                        selectionchange: {
                                            fn: function (dv, nodes) {
                                                alert('it works!');
                                            }
                                        }   
                                    }   
            }); 
        dv.render(document.body);
    }
    There are definitely no javascript errors, because this is a stripped down example of my problem. The script doesn't break.

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    I should have seen this before: You didn't configure a selection method!

    Use:
    Code:
    singleSelect:true
    or
    Code:
    multiSelect:true

  9. #9
    Sencha User
    Join Date
    Sep 2010
    Posts
    14

    Default

    Thank you so much! I misread the documentation, and thought singleSelect being false allows at most 1 selection, when, in fact, it doesn't allow selection at all.
    The problem is solved

Similar Threads

  1. Fire a Tree "SelectionChange" event when clicking the currently selected item
    By Cputerace in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 27 Feb 2009, 8:59 AM
  2. [2.??] Selectionchange event in dataview problem
    By sjerry in forum Ext 2.x: Bugs
    Replies: 3
    Last Post: 8 Feb 2009, 6:03 AM
  3. Replies: 1
    Last Post: 12 Mar 2008, 1:18 PM

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
  •