PDA

View Full Version : Help:append node to tree issue



winds512tom
6 Mar 2010, 3:11 AM
after append child node to a node which had not any child before,the node the style has not change what can't be expansed and collapsed .
http://b36.photo.store.qq.com/http_imgload.cgi?/rurl4_b=8792ea5a22e234a99ef04bc61d9cd68aec2a53d09da5ce446dc5d659ce4f50abf8a67d7a0fb7eda47303297959b2523c0b9f87aaeeaad64a0f7d1095171d18355c16ac79b527a9ee819864c67ce08123c8357de2&a=31&b=36
the red code about the insert action:

function prdTreeUpdatePanel(){
var id;
return new Ext.form.FieldSet({
id:'prdTreeFormPanel',
bodyStyle: 'padding:15px',
defaults: {
// applied to each contained item
width: 230,
msgTarget: 'side'
},
// title:'????',
labelWidth: 65,
bodyBorder:false,
items:[{
xtype:'radiogroup',
fieldLabel:'??',
id:'prdTreeformrole',
vertical: false,
items:[
{boxLabel: '??',name: 'prdTreeRadio1',inputValue: 2, checked:true},
{boxLabel: '??', name: 'prdTreeRadio1', inputValue: 1}
],
listeners:{
'change':function(g,checked){
Ext.getCmp('prdlevelnameparent').reset();
Ext.getCmp('prdlevelname').reset();
if(checked.getGroupValue()==1){
Ext.getCmp('prdformbuttondelete').show();
}else{
Ext.getCmp('prdformbuttondelete').hide();
}
}
}
},{xtype:'textfield',
// allowBlank:false,
id:'prdlevelnameparent',
name:'prdlevelnameparent',
disabled:true,
fieldLabel:'????'
},{xtype:'textfield',
// allowBlank:false,
id:'prdlevelname',
name:'prdlevelname',
fieldLabel:'??'
},{xtype:'textfield',
// allowBlank:false,
id:'prdId',
hidden:true
}],
buttons:[{
text:'??',
listeners:{
'click':function (){
var id=987;
var pid=Ext.getCmp('prdId').getValue();
var name=Ext.getCmp('prdlevelname').getValue();
var pnode = Ext.getCmp('prdTreePanel').getNodeById(pid);
pnode.appendChild(new Ext.tree.TreeNode({id:id,text:name,leaf:true}));
pnode.expand(false);

}
}
},{
text:'??',
hidden:true,
id:'prdformbuttondelete',
listeners:{
'click':function (){
Ext.Msg.confirm('Name', 'Please enter \n your name:', function(btn, text){
if(btn=='yes'){
alert('ok');
Ext.getCmp('prdlevelnameparent').setValue('');
}
else alert('false');

});
// alert(Ext.getCmp('prdId').getValue());
// Ext.getCmp('prdTreePanel').getNodeById(Ext.getCmp('prdId').getValue()).destroy();
}
}
}]

});
}

winds512tom
6 Mar 2010, 3:15 AM
after append child node to a node which had not any child before,the node the style has not change what can't be expansed and collapsed .


http://b36.photo.store.qq.com/http_imgload.cgi?/rurl4_b=8792ea5a22e234a99ef04bc61d9cd68aec2a53d09da5ce446dc5d659ce4f50abf8a67d7a0fb7eda47303297959b2523c0b9f87aaeeaad64a0f7d1095171d18355c16ac79b527a9ee819864c67ce08123c8357de2&a=31&b=36

the red code about is insert action :

function prdTreeUpdatePanel(){
var id;
return new Ext.form.FieldSet({
id:'prdTreeFormPanel',
bodyStyle: 'padding:15px',
defaults: {
// applied to each contained item
width: 230,
msgTarget: 'side'
},
// title:'????',
labelWidth: 65,
bodyBorder:false,
items:[{
xtype:'radiogroup',
fieldLabel:'??',
id:'prdTreeformrole',
vertical: false,
items:[
{boxLabel: '??',name: 'prdTreeRadio1',inputValue: 2, checked:true},
{boxLabel: '??', name: 'prdTreeRadio1', inputValue: 1}
],
listeners:{
'change':function(g,checked){
Ext.getCmp('prdlevelnameparent').reset();
Ext.getCmp('prdlevelname').reset();
if(checked.getGroupValue()==1){
Ext.getCmp('prdformbuttondelete').show();
}else{
Ext.getCmp('prdformbuttondelete').hide();
}
}
}
},{xtype:'textfield',
// allowBlank:false,
id:'prdlevelnameparent',
name:'prdlevelnameparent',
disabled:true,
fieldLabel:'????'
},{xtype:'textfield',
// allowBlank:false,
id:'prdlevelname',
name:'prdlevelname',
fieldLabel:'??'
},{xtype:'textfield',
// allowBlank:false,
id:'prdId',
hidden:true
}],
buttons:[{
text:'??',
listeners:{
'click':function (){
var id=987;
var pid=Ext.getCmp('prdId').getValue();
var name=Ext.getCmp('prdlevelname').getValue();
var pnode = Ext.getCmp('prdTreePanel').getNodeById(pid);
pnode.appendChild(new Ext.tree.TreeNode({id:id,text:name,leaf:true}));
pnode.expand(false);

}
}
},{
text:'??',
hidden:true,
id:'prdformbuttondelete',
listeners:{
'click':function (){
Ext.Msg.confirm('Name', 'Please enter \n your name:', function(btn, text){
if(btn=='yes'){
alert('ok');
Ext.getCmp('prdlevelnameparent').setValue('');
}
else alert('false');

});
// alert(Ext.getCmp('prdId').getValue());
// Ext.getCmp('prdTreePanel').getNodeById(Ext.getCmp('prdId').getValue()).destroy();
}
}
}]

});
}