Permalink
Browse files

even more flexible using autoValues

  • Loading branch information...
1 parent 8e16fa3 commit 29ab23918300d79753061ff7b67b1cfb7c618b70 @kristianmandrup committed Jun 25, 2012
Showing with 31 additions and 0 deletions.
  1. +13 −0 README.md
  2. +9 −0 SliderFieldInput.js
  3. +9 −0 SliderFieldText.js
View
13 README.md
@@ -39,6 +39,19 @@ This is an extended version of the Sencha Touch 2 Slider field with added helper
valueMap: ['A', 'B', 'C']
}
+## Using auto-values
+
+This will use values matching the valueMap passed in, in this example from 0 to 2, with initial value of 0 (override using defaultValue).
+
+ {
+ xtype: 'sliderfieldtext',
+ name: 'slider_decimal',
+ labelText: 'Decimal',
+ label: 'Decimal',
+ autoValues: true,
+ valueMap: ['Any', 'Apartment', 'House']
+ }
+
# Screenshots
View
9 SliderFieldInput.js
@@ -34,6 +34,15 @@ Ext.define('Ext.field.SliderInput', {
config.value = config.values;
}
+ if (config.hasOwnProperty('valueMap')) {
+ if (config.autoValues == true) {
+ config.value = config.defaultValue || 0;
+ config.minValue = 0;
+ config.maxValue = config.valueMap.size -1;
+ config.increment = 1;
+ }
+ }
+
this.callParent([config]);
},
View
9 SliderFieldText.js
@@ -33,6 +33,15 @@ Ext.define('Ext.field.SliderText', {
config.value = config.values;
}
+ if (config.hasOwnProperty('valueMap')) {
+ if (config.autoValues == true) {
+ config.value = config.defaultValue || 0;
+ config.minValue = 0;
+ config.maxValue = config.valueMap.size -1;
+ config.increment = 1;
+ }
+ }
+
this.callParent([config]);
},

0 comments on commit 29ab239

Please sign in to comment.