PDA

View Full Version : hello.i need help



kjcr
9 Nov 2012, 1:22 AM
hello.
I have problem with tree.
I want to set my root and all node checkbox.

in final node have checkbox.
But in root and other node don't have checkbox.

is there any solution about it?

This is my store


var storeTree = Ext.create('Ext.data.TreeStore', {
listeners: {
load:function(option){

},
append: function (thisNode, newChildNode, index, eOpts) {
//console.log(thisNode);
if (!newChildNode.isRoot()) {
newChildNode.set("text", newChildNode.get("text"));
}
}
},
proxy: {
type: 'memory'
},
sorters: [{
property: 'leaf',
direction: 'ASC'
}, {
property: 'text',
direction: 'ASC'
}]
});
and this is my tree:)


var tree = Ext.create('Ext.tree.Panel', {
store: storeTree,
rootVisible: false,
useArrows: true,
title: 'Tree',
id:'treeMenu',
split: true,
width: 300,
minWidth: 100,
maxWidth: 500,
height: 100,
minHeight: 60,
listeners : {
checkchange : function(node, checked) {
if(node.data.checked){
isAdd = true;
for(i=0;i<treeSelectNodeList.length;i++){
if(treeSelectNodeList[i] == key) isAdd = false;
}
if(isAdd==true) treeSelectNodeList.push(key);
}else{
for(i=0;i<treeSelectNodeList.length;i++)
if(treeSelectNodeList[i] == key) treeSelectNodeList.splice(i,1);
}
},
itemclick : function(grid, rowIndex, e,r) {
if(rowIndex.data.leaf){
tmp = rowIndex.data.qtitle.split("/");
miCode = tmp[1];
micCode = tmp[2];
Ext.get("rightContent").mask('Data Loading...');
key = rowIndex.data.id;
if(contents_panel.items.items[1].isVisible('activate')){
getXmlCode();
}
if(contents_panel.items.items[2].isVisible('activate')){
getPdfCode();
}

Ext.Ajax.request({
url: setUrlList.xmlTrans.url + '?idx='+key,
method: 'get',
failure : function(response){
Ext.get("rightContent").unmask();
Ext.Msg.alert('Error', 'system error.');
console.log(response);
},
success: xmlTrans
});
}
}
}
});

vietits
9 Nov 2012, 5:22 AM
To show checkbox for a node (leaf or folder), you should set checked property of that node to true (selected) or false (unselected). This node property has default value set to null which does not show the checkbox.

Albareto
9 Nov 2012, 6:38 AM
To show checkbox for a node (leaf or folder), you should set checked property of that node to true (selected) or false (unselected). This node property has default value set to null which does not show the checkbox.

I didn't know it, it is a very cool feature!

kjcr
12 Nov 2012, 5:33 PM
thankyou i make checkbox
and set value false.
below code is what i made



if (!newChildNode.isRoot()) {
newChildNode.set("checked", false);


the problem is when i click root check box.
i think all check box must click.

but no node is clicked.

is there any solution of this?

vietits
12 Nov 2012, 7:36 PM
Your thought is not default behavior of tree panel. Below is a solution. It will set all descendants to checked or unchecked basing on the status of checking node.


Ext.create('Ext.tree.Panel', {
...
listeners: {
...
checkchange: function(node, checked){
node.cascadeBy(function(){
this.set('checked', checked);
});
}
}
});

kjcr
12 Nov 2012, 8:35 PM
39994

if i check 2 then all 3 will be checked.
this is what i want to know.
sorry. :">

and i don't want check box in 1.
is there any solution about this?

and solution about when i uncheck 2 then all 3 will be unchecked.

help me please:)
thankyou~^^

vietits
12 Nov 2012, 9:16 PM
39994

if i check 2 then all 3 will be checked.
this is what i want to know.
sorry. :">

How do you distinguish 1 and 2? Example below applies the efffect for node that is not root node.


Ext.create('Ext.tree.Panel', {
...
listeners: {
...
checkchange: function(node, checked){
if(node.get('depth') > 0) { // put your condition here.
node.cascadeBy(function(){
this.set('checked', checked);
});
}
}
}
});



and i don't want check box in 1.
is there any solution about this?

Look at post #2: If you do not want to show checkbox for a node then do not set its 'checked' field or set this field to null.



and solution about when i uncheck 2 then all 3 will be unchecked.

The above solution also solves this requirement.

kjcr
12 Nov 2012, 9:38 PM
i make it!!
thankyou!