diff options
author | michael.leibman <michael.leibman@daa67922-0c33-11de-a42d-873b86d837ff> | 2009-12-15 10:13:55 +0000 |
---|---|---|
committer | michael.leibman <michael.leibman@daa67922-0c33-11de-a42d-873b86d837ff> | 2009-12-15 10:13:55 +0000 |
commit | 890c0622bf6dae2560f348f2c918d29dec672e68 (patch) | |
tree | b53c62ae70718e5641db04294b424a58a0a02d34 /slick.editors.js | |
parent | fa426e6b484dff88a585fe52c5f625da8fd0760f (diff) | |
download | SlickGrid-890c0622bf6dae2560f348f2c918d29dec672e68.zip SlickGrid-890c0622bf6dae2560f348f2c918d29dec672e68.tar.gz SlickGrid-890c0622bf6dae2560f348f2c918d29dec672e68.tar.bz2 |
Implemented an IntegerCellEditor. The current variation does accept decimals and just rounds them.
Diffstat (limited to 'slick.editors.js')
-rw-r--r-- | slick.editors.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/slick.editors.js b/slick.editors.js index 10e7774..9ad928b 100644 --- a/slick.editors.js +++ b/slick.editors.js @@ -119,6 +119,64 @@ var TextCellEditor = function($container, columnDef, value, dataContext) { this.init();
}
+var IntegerCellEditor = function($container, columnDef, value, dataContext) {
+ var $input;
+ var defaultValue = value;
+ var scope = this;
+
+ this.init = function() {
+ $input = $("<INPUT type=text class='editor-text' />");
+
+ if (value != null)
+ {
+ $input[0].defaultValue = value;
+ $input.val(defaultValue);
+ }
+
+ $input.appendTo($container);
+ $input.focus().select();
+ }
+
+
+ this.destroy = function() {
+ $input.remove();
+ }
+
+ this.focus = function() {
+ $input.focus();
+ }
+
+ this.setValue = function(value) {
+ $input.val(value);
+ defaultValue = value;
+ }
+
+ this.getValue = function() {
+ var val = $.trim($input.val());
+ return (val == "") ? 0 : parseInt($input.val(), 10);
+ }
+
+ this.isValueChanged = function() {
+ return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
+ }
+
+ this.validate = function() {
+ if (isNaN($input.val()))
+ return {
+ valid: false,
+ msg: "Please enter a valid integer"
+ };
+
+ return {
+ valid: true,
+ msg: null
+ };
+ }
+
+ this.init();
+}
+
+
var DateCellEditor = function($container, columnDef, value, dataContext) {
var $input;
var defaultValue = value;
|