PDA

View Full Version : Adding checkboxes to a tree panel



JustinW
6 Sep 2011, 5:58 AM
Hi,

I'd like to add checkboxes to a Ext.tree.Panel but I don't want to add a checked field to the model. Is there a way round this?

Thanks in advance :)

ramjhana
6 Sep 2011, 2:51 PM
I am new to Extjs, I am also facing adding checkbox..here is my code, i have highlighted the code for added a checkbox but the checkbox is getting displayed..

quick answer will be helpful

{
xtype:'fieldset'
,title:securityDomainsKeyConfig
,labelWidth:100
,collapsible:false
,layout:'column'
,items:[{
columnWidth:.45
,layout:'form'
,labelWidth:170
,items:[{
xtype:'vivoDisplayField'
,name:'sdMasterKeys'
,hideLabel:true
,value: securityDomainsMasterKey+' <span style=color:red>*</span>'

//},{
,xtype: 'fieldset', //BharathRam..Begin..defining the type of component
items: [
{
type: 'checkboxfield',
name:'Scp02',
label:'Scp02',
id: 'Scp02',
checked: true,
listeners: {
check: function() {
alert(this.getUrl);
if(Ext.getCmp('mkConfig1') != undefined)
Ext.getCmp('mkConfig1').setValue(false);
Ext.getCmp('mkConfig0').setValue(true);
Ext.getCmp('divKeyName').enable();
Ext.getCmp('divKeyName').setValue("");
Ext.getCmp('divLogicid').enable();
Ext.getCmp('divLogicid').setValue("");
Ext.getCmp('sdDKeyVersion').enable();
Ext.getCmp('sdDKeyVersion').setValue("");
Ext.getCmp('divMacKeyName').enable();
Ext.getCmp('divMacKeyName').setValue("");
Ext.getCmp('divDekKeyName').enable();
Ext.getCmp('divDekKeyName').setValue("");
Ext.getCmp('divMacLogic').enable();
Ext.getCmp('divMacLogic').setValue("");
Ext.getCmp('divDekLogic').enable();
Ext.getCmp('divDekLogic').setValue("");
Ext.getCmp('encKeyName').disable();
Ext.getCmp('macKeyName').disable();
Ext.getCmp('decKeyName').disable();
Ext.getCmp('sdSKeyVersion').disable();
},
uncheck: function() {
//do something
}
}//listeners closed
}] //Items Closed
},{

//BharathRam - end
xtype:'radiogroup'
,name:'masterKeyConfig'
,hideLabel:true
,items:[{boxLabel:securityDomainsStatic, name:'mkConfig', id:'mkConfig0', inputValue:0,
listeners: {
check:function(comp, value){
if(comp.id == "mkConfig0" && value == true){
if(Ext.getCmp('mkConfig1') != undefined)
Ext.getCmp('mkConfig1').setValue(false);
Ext.getCmp('mkConfig0').setValue(true);
Ext.getCmp('divKeyName').disable();
Ext.getCmp('divKeyName').setValue("");
Ext.getCmp('divLogicid').disable();
Ext.getCmp('divLogicid').setValue("");
Ext.getCmp('sdDKeyVersion').disable();
Ext.getCmp('sdDKeyVersion').setValue("");
Ext.getCmp('divMacKeyName').disable();
Ext.getCmp('divMacKeyName').setValue("");
Ext.getCmp('divDekKeyName').disable();
Ext.getCmp('divDekKeyName').setValue("");
Ext.getCmp('divMacLogic').disable();
Ext.getCmp('divMacLogic').setValue("");
Ext.getCmp('divDekLogic').disable();
Ext.getCmp('divDekLogic').setValue("");
Ext.getCmp('encKeyName').enable();
Ext.getCmp('macKeyName').enable();
Ext.getCmp('decKeyName').enable();
Ext.getCmp('sdSKeyVersion').enable();
}
},
afterrender:function(component){
Ext.getCmp('mkConfig0').setValue(true);

}
}
}]
}

skirtle
8 Sep 2011, 12:46 AM
@ramjhana. Your question is completely unrelated. Please do not hijack other people's questions. I believe your problem is due to the line type: 'checkboxfield'.

@JustinW. Without doing a lot of work I think you're stuck with having a checked field. Why is this a problem?

JustinW
12 Sep 2011, 9:24 AM
Hi Skirtle,

Thanks for the reply.

We were trying to keep to dynamically generated models for this particular piece of our development. Since checked isn't a column returned by the db it's not on our dynamic list of fields. I think we'll just work round it by adding it as a field when we build our models.

skirtle
12 Sep 2011, 9:37 AM
It should be one of the 20 or so fields that get added to the model automatically when you use it in a tree. Shouldn't need to add it manually to the model.

JustinW
12 Sep 2011, 9:48 AM
Thanks for the speedy response :)

I've seen the property on the tree but it seems to be set to null unless I add the field manually to the model, the null (as opposed to true or false) seems to result in the checkbox not appearing... Any ideas?

skirtle
12 Sep 2011, 9:57 AM
Are we perhaps talking about different things? Adding the field to the model would mean doing this:


Ext.define(..., {
extend: 'Ext.data.Model',
fields: [..., 'checked']
});

Is that what you mean? I suspect you're referring to including a checked field in your data rather than your model. If so, then the obvious question is where else would you want to specify what value to show in the checkbox? It may be possible, just not sure what sort of alternative you'd want.