API Docs for:
Show:

Y.DataTable.EditorOptions.inlineNumber Class

Inline Cell Editor "inlineNumber"

This View configuration is used to setup an editor referenced as "inlineNumber" as a simple inline-type cell editor. It is identical to the "inline" textual editor but incorporates Numeric validation prior to saving to the DT.

Basic Usage:
    // Column definition
    { key:'unit_price', editor:"inlineNumber" }

    // Column definition ... to allow integers only
    { key:'QuantityInStock', editor:"inlineNumber", editorConfig:{ keyFiltering: /\d/ }  }
Standard Configuration

This inline editor creates a simple INPUT[type=text] control and positions it to match the underlying TD node. A saveFn is defined that uses an ad-hoc attribute "validationRegEx" to test for validity prior to saving the data. If the value passes validation it is converted to numeric form and returned.

The configuration {Object} for this cell editor View is predefined as;

     Y.DataTable.EditorOptions.inlineNumber = {
         BaseViewClass:  Y.DataTable.BaseCellInlineEditor,
         name:           'inlineNumber',
         hideMouseLeave: false,

         // Define a key filtering regex ... only allow digits, "-" or "."
         keyFiltering:   /\.|\d|\-/,

         // setup a RegExp to check for valid floating point input ....
         validator: /^\s*(\+|-)?((\d+(\.\d*)?)|(\.\d*))\s*$/,

         // Function to call after numeric editing is complete, prior to saving to DataTable ...
         //  i.e. checks validation against ad-hoc attribute "validationRegExp" (if it exists)
         //       and converts the value to numeric (or undefined if fails regexp);
         saveFn: function(v){
             var vre = this.get('validationRegExp'),
                 value;
             if(vre instanceof RegExp) {
                 value = (vre.test(v)) ? +v : undefined;
             } else {
                 value = +v;
             }
             return value;
         }
     };

PLEASE NOTE: All other attributes from the BaseViewClass apply and can be included within the editorConfig object.

Item Index

Attributes

Attributes

validator

RegExp | Function

A validation regular expression object used to check validity of the input floating point number. This can be defined by the user to accept other numeric input, or set to "null" to disable regex checks.

Default: /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/