PDA

View Full Version : Dataview question



ing.amdangelo
7 May 2012, 5:46 AM
How can i select a dataview elements on render ??

var fields = [
{ name: 'idTemplate', mapping: 'string:nth(1)' },
{ name: 'nomeTemplate', mapping: 'string:nth(2)' },
{ name: 'nomefileTemplate', mapping: 'string:nth(3)' },
{ name: 'icona', mapping: 'string:nth(4)' }
];


var params = {
autoLoad: true,
record: 'ArrayOfString'
}


var storeTemplate = createXMLStore('ajax.asmx/getListTemplateAttestati', fields, params);


storeTemplate.on("load", function (store, dati, options) {
for (var i = 0; i < dati.length; i++) {
if (dati[i].data.idTemplate == convegno.IdAttestato) {
Here i would select the dataview element
}
}
});




var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}">',
'<div class="thumb"><img src="../css/templateAttestati/{icona}" title="{nomeTemplate}"></div>',
'<span>{nomeTemplate}</span></div>',
'</tpl>',
'<div class="x-clear"></div>'
);


var modificaTemplatePanel = new Ext.form.FieldSet({
id: 'dataviewTemplate',
collapsible: true,
layout: 'fit',
title: 'Attestato',
items: new Ext.DataView({
store: storeTemplate,
tpl: tpl,
id: 'selectAttestatoModifica',
singleSelect: true,
overClass: 'x-view-over',
itemSelector: 'div.thumb-wrap',
emptyText: 'Non ci sono Template per gli ATTESTATI',
listeners: {
dblclick: function (_this, index, node, e) {
var record = _this.store.getAt(index);
var mConfig = {
mediaType: 'PDF',
url: '../css/templateAttestati/' + record.data.nomefileTemplate,
unsupportedText: 'Acrobat Viewer is not Installed',
resizable: true
};
var p = new Ext.ux.MediaWindow({
id: 'PDFViewerWin',
bodyStyle: 'position:relative; padding:0px;',
width: 800,
height: 600,
mediaCfg: mConfig,
title: record.data.nomeTemplate,
fbar: {
items: ['->',
{
text: 'Chiudi',
handler: function () {
p.close();
}
}
]
}
}).show();
}
}
})
});

scottmartin
14 May 2012, 6:41 AM
Can you use the DataView.select()/selectRange() methods?

Regards,
Scott.

sword-it
15 May 2012, 12:03 AM
Hi,

You may use 'afterrender' event of Dataview which provides your Dataview as a argument.Inside that, you can easily select your nodes.

TWO METHODS OF SELECTING

Method1:-
if you want to select a single or multiple nodes as per your needs, you may use 'select' method of dataview.
For details, check this http://docs.sencha.com/ext-js/3-4/#!/api/Ext.DataView-method-select

Method2:-
Also, if you just want to select a particular range of nodes from starting to an end let's say first 10 nodes, you may use 'selectRange' method in which needs starting and ending indexes of your nodes in Dataview.
For details, check this http://docs.sencha.com/ext-js/3-4/#!/api/Ext.DataView-method-selectRange