2 Attachment(s)
FieldSet modified to be similar to gmail Contacts
Great plugin, didn't quite do what I wanted so I've changed it somewhat.
Perhaps my changes can be integrated to compliment what you've done with the fieldsets rather than replace it. But I replaced it for now as it was easier to get my head around how it all worked.
My changes have altered the way the fieldset cloning works, in short the fieldset + tool doesn't clone a fieldset. Instead it clones a row of column, form, fields within a fieldset. Very similar behavior to gmail 'Contacts' edit form.
Changes have been made to field.js to allow multiple columns within a fieldset
fieldsets are still configured as dynamic, however they have layout:'column'
Code:
dynamic : true,
maxOccurs:5,
xtype : 'fieldset',
layout:'column',
nameSpace:'person',
autoHeight:true,
width: 600,
listeners : { 'maxoccurs' : {fn: function(fieldset) {
Ext.example.msg('maxoccurs', 'Implement behaviour of maxoccurs');
}}},
Because you can't define a form element in a column you need to have a nested form with you're desired columnWidth, each form should contain only one field, notice dynamic is no configured
Code:
items :[{
layout:'form',
columnWidth:.5,
defaultType: 'textfield',
items:[{
fieldLabel: 'First Name',
name: 'first',
//dynamic:true,
}]
},{
layout:'form',
columnWidth:.5,
defaultType: 'textfield',
items:[{
fieldLabel: 'Last Name',
name: 'last',
}]
}]
That aside I'll e-mail the other changes to arnold in the Ext.form.FormPanel and Ext.form.FieldSet.
More updates to come possibly, need to discuss with arnold.
26-Jun-2009 - updated FormPanel extract so fieldset extract returns array(rows) of objects(fields)
rendering JSON objects into a proxy url
Hey all,
I just used this. It works great but taking the values was such a pain for me. I wanted to give a tip if you were taking the values of this and trying to loop through them to put in a url. It might also help if you were trying to do anything with the values. The main point is that 1 JSON is a string obj and 2 items(clones) are a array.
I had a form with 2 fields in a fieldset named 'parameters' and 'userInput' using the nameSpace property and 'paras' and 'daInputField' for the names property. this is what i had to do to get the values of those fields...
Code:
var panel = Ext.getCmp('panel');
var fparams = panel.extract('Parameters','field');
var fuserInput = panel.extract('userInput','field');
var t_url = "";
var sep= "";
//This is what took me forever to figure out because 1 JSON object is a string and 2+ JSON objects are a array!!!!
if(typeof(fparams.Paras) == 'string'){
//i'm a string
t_url = fparams.Paras + "=" + fuserInput.daInputField;
}else{
//i'm a array
for(var i=0; i<fparams.Paras.length; i++){
t_url += sep+ fparams.Paras[i] + "=" + fuserInput.daInputField[i];
sep = "&";
}
}
//this is for my project but maybe you do something like this...
var z_url = proxy.url;
proxy.url += t_url;
ds.load();
proxy.url = z_url;
t_url = "";
Again I might have just not known that since this is my first time using JSON but maybe someone else has had the same problem...
cheers,
k_lib
Removing clones on form reset
Thank you for a great extension!
There's a few changes I would like to do for it to apply to what I am doing. First was just removing clone labels and that wasn't too bad (just add hideLabel : true to cloneConfig). Another change I would like to do is to delete all clones on a form reset. I've tried adding a removeClones function for Ext.form.formpanel but my limited experience (about a month) in extjs (and javascript) isn't helping me at all. I would greatly appreciate it if somoene could take a look at what I have below and point me to the right direction.
What I added into Ext.form.FormPanel is removeClones and findFieldsets.
removeClones that will find fieldsets and then remove them.
Code:
removeClones : function(ns, xtype) {
var fieldsets = this.findFieldsets();
//iterate through fieldsets and remove clones
for (var col = fieldsets.length; col > 0; col++) {
if (fieldsets[col].isClone()) {
fieldsets[col].remove();
}
}
},
findFieldsets that should return an array of all fieldsets. I think this is where I am going wrong as this isn't actually returning an array of all fieldset components.
Code:
findFieldsets : function () {
return this.findBy(function(cmp) {
return cmp.isXType('fieldset');
});
},
//rest of code
Finally, in Jamie.nicholson's Ext.form.Fieldset, I added a check for clones and the actual removal of the fieldset.
Code:
isClone : function() {
if (this.clone) {
return true;
}else {
return false;
}
},
remove : function() {
if (this.dynamic) {
if (this.clone) {
var panel = fieldset.ownerCt;
panel.remove(fieldset,true);
panel.doLayout();
}
}
},