Y.DataTable.EditorOptions.inlineDate Class
Inline Cell Editor "inlineDate"
This View configuration is used to setup an editor referenced as "inlineDate" 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:'weddingDate', editor:"inlineDate" }
// Column definition with user-specified 'dateFormat' to display Date in text box on display
{ key:'date_of_claim', editor:"inlineDate", editorConfig:{ dateformat:'%Y-%m-%d'} }
Standard Configuration
This inline editor creates a simple INPUT[type=text] control and positions it to match the underlying TD node. Since
a JS Date object isn't very pretty to display / edit in a textbox, we use a prepFn
to preformat the Date in a
human-readable form within the textbox. Also a saveFn
is defined to convert the entered data using Date.parse
back to a valid JS Date prior to saving to the DT.
The configuration {Object} for this cell editor View is predefined as;
Y.DataTable.EditorOptions.inlineDate = {
BaseViewClass: Y.DataTable.BaseCellInlineEditor,
name: 'inlineDate',
// Define default date format string to use
dateFormat: "%D",
// Setup input key filtering for only digits, "-" or "/" characters
keyFiltering: /\/|\d|\-/,
// Function to call just prior to populating the INPUT text box,
// so we pre-format the textbox in "human readable" format here
prepFn: function(v){
var dfmt = this.get('dateFormat') || "%m/%d/%Y";
return Y.DataType.Date.format(v,{format:dfmt});
},
// Function to call after Date editing is complete, prior to saving to DataTable ...
// i.e. converts back to "Date" format that DT expects ...
saveFn: function(v){
return Y.DataType.Date.parse(v);
}
};
PLEASE NOTE: All other attributes from the BaseViewClass
apply and can be included within the
editorConfig
object.