PDA

View Full Version : Using setValues on form - can't figure it out



Niels Brouwers
2 Jul 2009, 7:13 AM
So I have a form that was largely copy/pasted from an example. I'm new at ExtJS so forgive me if some of the flags and config settings look odd. In any case, I want to fill the data in the form using setValues. Using getValues I can retrieve a map of all the name/value pairs. Now here's the odd thing: if I get the values using getValues(), modify a single property, and write it back using setValues() the form doesn't get updated. It looks like there's either a bug or feature I'm missing that makes checkboxes nested a group not work.



// get values from the form.
values = form.getValues();
// Assume the 'create' checkbox is checked, we'll get something like "values.create='on'"
console.log(values);
// now uncheck the checkbox
values.create = 'off';
// write back the changed value set. This somehow does not update the checkbox on the screen
form.getValues(values);


I've been hacking at this for three full hours but have been unable to come up with a solution/patch. I hope someone here can help me out :)


// properties form
var permissionsForm = new Ext.form.FormPanel (
{
layout:'fit',
autoHeight: true,
autoWidth: true,
items: [
new Ext.form.FieldSet(
{
title : 'Permissions',
layout: 'form',
autoHeight: true,
autoWidth: true,
items: [
// profile combobox
new Ext.form.ComboBox({
name: 'profile',
fieldLabel: 'Profile',
store: [ 'Full control', 'Owner', 'Secretary', 'Only read', 'No rights', 'Other' ],
displayField: 'name',
mode: 'local',
triggerAction: 'all',
forceSelection:true,
selectOnFocus: true
}),

new Ext.form.CheckboxGroup({
name: 'checkboxes',
hideLabel: true,
anchor: '95%',
// Distribute controls across 3 even columns, filling each row
// from left to right before starting the next row
columns: 2,
items: [{
columnWidth: 0.5,
items: [
{boxLabel: 'Create items', name: 'create'},
{boxLabel: 'Read items', name: 'read'},
{boxLabel: 'Create subfolders', name: 'createSubFolders'},
]
}, {
columnWidth: 0.5,
items: [
{boxLabel: 'Folder permissions', name: 'folderPermissions'},
{boxLabel: 'Folver visible', name: 'folderVisible'}
]
}]
}),

{
xtype: 'radiogroup',
itemCls: 'x-check-group-alt',
hideLabel: true,
allowBlank: false,
anchor: '95%',
items: [{
columnWidth: '.5',
items: [
{xtype: 'label', text: 'Edit', cls:'x-form-check-group-label', anchor:'-15'},
{boxLabel: 'None', name: 'edit', inputValue: 1},
{boxLabel: 'Own', name: 'edit', inputValue: 2},
{boxLabel: 'Any', name: 'edit', inputValue: 3},
]
},{
columnWidth: '.5',
items: [
{xtype: 'label', text: 'Delete', cls:'x-form-check-group-label', anchor:'-15'},
{boxLabel: 'None', name: 'delete', inputValue: 1},
{boxLabel: 'Own', name: 'delete', inputValue: 2},
{boxLabel: 'Any', name: 'delete', inputValue: 3}
]
}]
}
]
})
]
});

jakeext
2 Jul 2009, 7:20 AM
I assume you meant to say

form.setValues(values);

instead of

form.getValues(values);


Not sure why it's not working - you could try creating your own hard-coded object hash or id/value array and call setValues with that object or array and see if the values change in that case.

Niels Brouwers
2 Jul 2009, 7:28 AM
I tried both, neither work. The problem is that both implementations call findField, which returns null for anything but the combobox.