PDA

View Full Version : [SOLVED] DataView selectionchange event doesn't fire



amcsi
10 Sep 2010, 1:34 AM
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:


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 :(

Condor
10 Sep 2010, 2:00 AM
Which Ext version? I seem to recall a bug that could cause this.

amcsi
10 Sep 2010, 2:13 AM
3.2.1

Condor
10 Sep 2010, 2:24 AM
And you don't get any errors?

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

amcsi
10 Sep 2010, 3:34 AM
Firebug doesn't show any errors
I made jslint like the code. Still doesn't work :/

Condor
10 Sep 2010, 3:48 AM
Strange... Can you post the code you have now after fixing the warnings?

amcsi
10 Sep 2010, 3:50 AM
/* 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.

Condor
10 Sep 2010, 3:59 AM
I should have seen this before: You didn't configure a selection method!

Use:

singleSelect:true
or

multiSelect:true

amcsi
10 Sep 2010, 4:55 AM
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 :)