yui datatable 可编辑文本框的设置

  在使用yui的过程中,因为很多资料都是英文的,没有花太多的时间细究其中的各种实现细节。一旦范例能够满足要求就安心使用下去了。

  yui的范例都非常有效。但有个问题很麻烦,界面上可编辑文本框的按钮都是英文,显然对于一个中文后台系统,英文的按钮对整体有着不和谐的感觉。唯一的办法就是yui的本土话。

  当时,照着这个问题google了一下,结果没有一个是我需要的答案。即使是类似的搜索,还是难以找到。

  实在没法,就在yahoo的developer站点的狂找。终于在某个很容易忽略的角落发现了一些蛛丝马迹。

  官方的描述如下:

  

You can pass in configuration options into the CellEditor constructor as an object literal to customize certain behaviors of the editor, such as input validation or default values. Please refer to the API documentation for more information on which properties are supported for each type of CellEditor.

Common CellEditor properties
PropertyTypeDescription
asyncSubmitter Function Implementer defined function that can submit the input value to a server. This function must accept the arguments fnCallback and oNewValue. When the submission is complete, the function must also call fnCallback(bSuccess, oNewValue) to finish the save routine in the CellEditor. This function can also be used to perform extra validation or input value manipulation.
defaultValue Mixed Default value to use in CellEditor if Record data value is undefined.
disableBtns Boolean True if Save/Cancel buttons should not be displayed in the CellEditor.
LABEL_CANCEL String Text to display on Cancel button.
LABEL_SAVE String Text to display on Save button.
validator Function Validator function for input data returns either the validated (or type-converted) value or undefined. Implementers can use the built-in validator function YAHOO.widget.DataTable.validateNumber or provide their own custom function.

  大体意思可以通过在编辑器构造(姑且用这个词汇),注入配置信息。

  非常好的创建模式。然后针对这个写了一个简单的YahooEditorHelper类,按钮本土化的问题就算解决了。

  唯一的遗憾,找不找一种全局界面语言设定的方法。

  还有就是自己英文太差!要继续努力呀!

原文地址:https://www.cnblogs.com/kathmi/p/1414196.html