PDA

View Full Version : Choosing only one value



Valik71
26 May 2013, 12:58 AM
I have a tree with a list of folders is displayed in a popup window. It is necessary to be able to choose only one value. None of this helps

var selectFolder=function(taskid){
var form = Ext.create('Ext.form.Panel', {
layout: 'absolute',
border: false,
bodyPadding: 5,
items: [
{
xtype:'fieldset',
title: '?????',
width:500,
defaultType: 'displayfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items :[
{
xtype: 'treepanel',
rootVisible: false,
useArrows: true,
id: 'folder',
border: false,
expand: true,
simpleSelect : true,
//multiSelect: true,
hideCollapseTool: true,
height: 400,
store: Ext.create('Ext.data.TreeStore', {
fields: [
{name: 'text', type: 'string'},
{name: 'id', type: 'string'},
{name: 'pid',type:'string'},
{name: 'parent',type:'int'},
{name: 'pindex',type:'int'}
],
proxy: {
type: 'ajax',
url: 'tm_task_tree.php?e=getFolders'
},
root: {
expanded: true,
icon: 'tpl/def/img/user-home.png',
id: 0
},
sorters: [{
property: 'type',
direction: 'ASC'
},{
property: 'pindex',
direction: 'ASC'
}],
})
}
]
}
],
buttons: [{
width : 105, height: 30,
text: '?????????',
tooltip: '???????? ? ????????? ?????',
handler: function() {
var item = Ext.getCmp('folder').getView().getChecked();
console.log(item[0].internalId),
Ext.Ajax.request({
url: 'inc/ajax/tm_task.php?e=setFolderTask',method: 'POST',
params: {
id: taskid,
},
success: function (result, request) {
Ext.getCmp('getSelect').close();
}
});
}
},
{
xtype: 'button',
width : 110, height: 30,
text: '??????',
tooltip: '?????? ?? ??????',
handler: function() {
Ext.getCmp('getSelect').close();
}
}],

});

As can select only one value.

Farish
27 May 2013, 1:00 AM
By default, its only possible to select one node in a tree panel and multiSelect is disabled unless you turn it on. See the example in the documentation:

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.tree.Panel

Click on "Live Preview" and try it.

Valik71
28 May 2013, 8:58 AM
You think I have not seen it? None of this I could not apply.
How can I do to select only one value?
Just experience with ExtJS small.

Farish
28 May 2013, 9:14 AM
Please try to remove any code which is not necessary and create a simplified example and put it on jsfiddle.net. Why have you put the treepanel inside a fieldset? add it directly to your form.

I am not really sure that I understand the problem you are having.