// 通过属性设置选项
var editor = new YAHOO.ext.grid.NumberEditor();
editor.allowBlank = false;
editor.minValue = 10;
editor.minText = "Nice try buddy, %0 is too small.";
//通过配置对象设置选项
var editor = new YAHOO.ext.grid.NumberEditor({allowBlank: false, minValue: 10,
minText: "Nice try buddy, %0 is too small."});
//设置最大最小值,NumberEditors的西班牙文错误提示
YAHOO.ext.grid.NumberEditor.prototype.minText = "La cantidad debe ser menos de %0";
YAHOO.ext.grid.NumberEditor.prototype.maxText = "La cantidad debe ser más de %0";
预定义编辑器Predefined Editors
当前的编辑器已经实现的功能:
文本编辑器TextEditor 提供一个简单的文本编辑器,下列是配置选项:
allowBlank - True if the cell is allowed to be empty.
selectOnFocus - True to select the text when the editor is activated.
blankText - The tooltip (error message) to display when the cell is empty and is not allowed to be.
regex - A regular expression to match if the value is valid. If the regex.test(value) returns false, the value is considered invalid.
regexText - The tooltip (error message) to display when regex does not match.
validator - Any custom validation function you want called. The function must return true if the data is valid or an error message otherwise.
validationDelay - The delay in milliseconds for validation. Each time the user types something the field is validated after a specified delay, setting this value allows you to customize that delay (for example, if your custom validation routine is slow).
数字编辑器 NumberEditor
allowDecimals - True if the cell can have decimal values.
decimalSeparator - Character(s) to allow as the decimal separator.
decimalPrecision - Set the maximum decimal precision.
decimalPrecisionFcn - Define the function to call to remove extra precision (ie. Math.floor, Math.round, Math.ceil or your own function).
allowNegative - True if the cell allows negative values.
selectOnFocus - True to select the text when the editor is activated.
minValue - The minimum value the cell will allow.
maxValue - The maximum value the cell will allow.
minText - The tooltip to display when the value in the cell is below the minimum.
maxText - The tooltip to display when the value in the cell is above the maximum.
nanText - The tooltip to display when the value in the cell is not a valid number (for example, negatives are allowed and the value in the cell is just "-" with no numbers).
format - The date format for the editor. The format is now identical to PHP date() and text is allowed. Credit for that goes to this fantastic date library. This format is for the editor only and doesn't affect the rendering of the cell when not in edit mode. Your rendering function can use any date format it wants.
minValue - The minimum allowed date. Can be either a Javascript date object or a string date in the specified format.
maxValue - The maximum allowed date. Can be either a Javascript date object or a string date in the specified format.
minText - The tooltip to display when the date in the cell is before minValue.
maxText - The tooltip to display when the date in the cell is after maxValue.
invalidText - The text to display when the date in the field is invalid (for example: 02/31/06)
disabledDays - An array of days to disable, 0 based. For example, [0, 6] disables Sunday and Saturday.
disabledDaysText - The tooltip to display when the date in the cell (or DatePicker) falls on a disabled day.
disabledDates - An array of "dates" to disable, as strings. These strings will be used to build a dynamic regular expression so they are very powerful. For example, ["03/08/2003", "09/16/2003"] would disable those dates, but ["03/08", "09/16"] would disable them for every year. If you are using short years, you will want to use ^ to tell the regular expression to only match the beginning like ["^03/08"]. To disable March of 2006: ["03/../2006"] or every March ["^03"]. In order to support regular expressions, if you are using a date format that has "." in it, you will have to escape the dot when restricting dates. For example: ["03.08.03"].
disabledDatesText - The tooltip to display when the date in the cell (or DatePicker) falls on a disabled date.
NumberEditor.decimalPrecision, NumberEditor.decimalPrecisionFcn - Support for decimal precision and rounding etc. See the thread in the forum for details.
Shift-tab to navigate backwards, enter moves down 1 cell.
DatePicker changes: Highlights selected date, highlights today, restricts selection based on min/max values for the DateEditor.
Hiding and "Unhiding" of columns programmatically. You can also start columns in a hidden state.
More DateEditor/Picker enhancements: disabling of days (i.e. Saturday and Sunday), and disabling of individual dates/date ranges/dates each year. The disabling of the dates is accomplished by dynamically building a regular expression so it is very flexible and very fast. See DateEditor above for more details. The date format specifiers are different now and match the PHP date() function instead of Java mm/dd/yy style. The reason is I integrated this small date lib and got rid of my own date parsing code. It's faster and also support dates with text now, such as 15-Mar-06.
Regular expression validation on the TextEditor without using a validator function.