PDA

View Full Version : Checbox name and value not set



msenhaji
10 Jul 2012, 7:37 AM
Hi, i am facing a problem with checkboxes. I created a checbox group with 4 items but it seems that the names and the values are not set. And when i submit the form no parameters are sent ... ?

Could you please help me ?

here is my JS Code :




Ext.onReady(function(){

var checkbox = {
// Use the default, automatic layout to distribute the controls evenly
// across a single row
xtype: 'checkboxgroup',
columns: 2,
vertical: true,
items: [
{boxLabel: 'Sortie de Geozone', name: 'd_rulenotifselector', inputValue: 'depart()'},
{boxLabel: 'Entre dans Geozone', name: 'd_rulenotifselector', inputValue: 'arrive()'},
{
boxLabel: 'Dépassement de vitesse',
name: 'd_rulenotifselector',
inputValue: 'overSpeed()',
listeners: {
change : {
fn : function(checkbox, checked){
alert('test reussi');
}
}
}
},
{boxLabel: 'Batterie faible', name: 'd_rulenotifselector', inputValue: 'batteryLow()'},
]
};

var panel = Ext.create('Ext.form.Panel', {
renderTo: 'notificationPanel',
title: 'Gestion des Notifications',
xtype: 'container',
hidden: true,
bodyPadding: 10,
items: [
checkbox
]
});

var useNotifSelect = Ext.get('d_ruleallw');
useNotifSelect.addListener('change', function(evt, el ,o){
if(useNotifSelect.getValue(false)){
panel.show();
}else {
panel.hide();
}
});
if(useNotifSelect.getValue(false)){
panel.show();
};

});


Thanks in advance

scottmartin
10 Jul 2012, 4:58 PM
This seems to work:



Ext.create('Ext.form.Panel', {
title: 'Checkbox Group',
width: 300,
height: 150,
bodyPadding: 10,
renderTo: Ext.getBody(),
items:[{
xtype: 'checkboxgroup',
fieldLabel: 'Two Columns',
// Arrange checkboxes into two columns, distributed vertically
columns: 2,
vertical: true,
items: [
{ boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
{ boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },
{ boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
{ boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
{ boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
{ boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
]
}],

buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
}
}]

});


headers tab in submit: (2/5 checked)
rb:2
rb:5

Scott.

msenhaji
11 Jul 2012, 12:37 PM
Yes but in your case you added a submit button within your panel. In my case the panel is integrated in an existing form with already a submit button.

scottmartin
11 Jul 2012, 12:49 PM
Please present a full working example of what you have in place.

Scott.