[]
↳ ComboBox
• new ComboBox()
表示一个可编辑的组合框单元格。
example
// 此示例创建一个组合框单元格。
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.items(["a","b","c"]);
activeSheet.getCell(2, 2).cellType(cellType2);
• typeName: string
表示用于支持序列化的类型名称字符串。
▸ activateEditor(editorContext, cellStyle, cellRect, context?): void
激活编辑器,包括设置编辑器的属性或属性以及绑定编辑器的事件。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
cellStyle |
Style |
单元格的实际样式。 |
cellRect |
Rect |
单元格的布局信息。 |
context? |
any |
与单元格类型相关的上下文。 |
void
▸ allowFloat(value?): any
获取或设置是否允许组合框的弹出菜单溢出Spread。
example
// 此示例设置allowFloat方法。
var items2 = ["a", "ab", "abc", "apple", "boy", "cat", "dog"];
var comboBoxCellType = new GC.Spread.Sheets.CellTypes.ComboBox().items(items2);
comboBoxCellType.allowFloat(false);
activeSheet.getCell(1, 3).cellType(comboBoxCellType);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
是否允许组合框的弹出菜单溢出Spread。 |
any
如果未设置值,则返回复合框的弹出菜单是否允许溢出Spread;否则返回复合框单元格类型。
▸ createEditorElement(context?): HTMLElement
创建一个 DOM 元素并返回它。
| Name | Type | Description |
|---|---|---|
context? |
any |
与单元格类型相关的上下文。 |
HTMLElement
返回一个 DOM 元素。
▸ dataBinding(value?): IDataBinding | ComboBox
获取或设置组合框单元格类型的数据绑定。
example
// 此示例显示将表名绑定到组合框单元格类型。
var tableName = { dataSource: "productName", text: "productName", value: "productId" };
var cellType = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType.dataBinding(tableName);
activeSheet.getCell(1, 3).cellType(cellType);
example
// 此示例显示将公式绑定到组合框单元格类型。
var formula = { dataSource: '=SORT(UNIQUE(QUERY("Products", {"productName","productId"})))', text: 0, value: 1 };
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.dataBinding(formula);
activeSheet.getCell(10, 3).cellType(cellType2);
| Name | Type | Description |
|---|---|---|
value? |
IDataBinding |
组合框的数据绑定。 |
如果未设置值,则返回复合框的数据绑定;否则返回复合框单元格类型。
▸ deactivateEditor(editorContext, context?): void
停用编辑器,例如取消绑定编辑器的事件。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
context? |
any |
与单元格类型相关的上下文。 |
void
▸ editable(value?): any
获取或设置是否可编辑组合框。
example
// 此示例设置editable方法。
var items2 = ["a", "ab", "abc", "apple", "boy", "cat", "dog"];
var eComboBoxCellType = new GC.Spread.Sheets.CellTypes.ComboBox().items(items2).editable(true);
activeSheet.getCell(1, 3).cellType(eComboBoxCellType);
activeSheet.setColumnWidth(0,120);
activeSheet.setColumnWidth(2,120);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
是否可编辑组合框。 |
any
如果未设置值,则返回复合框是否可编辑;否则返回复合框单元格类型。
▸ editorValueType(value?): any
获取或设置写入基础数据模型的值。
example
// 此示例获取类型。
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.items(["a","b","c"]);
activeSheet.getCell(2, 2).cellType(cellType2);
alert(cellType2.editorValueType());
| Name | Type | Description |
|---|---|---|
value? |
EditorValueType |
编辑器的值类型。 |
any
如果未设置值,则返回复合框的值类型;否则返回复合框单元格类型。
▸ focus(editorContext, context?): void
聚焦编辑器 DOM 元素。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
context? |
any |
与单元格类型相关的上下文。 |
void
▸ format(value, format, formattedData?, context?): string
使用指定的格式格式化一个值。
| Name | Type | Description |
|---|---|---|
value |
any |
要格式化的对象值。 |
format |
string | GeneralFormatter |
格式。 |
formattedData? |
FormattedData |
格式化的数据。 |
context? |
any |
与单元格类型相关的上下文。 |
string
返回格式化的字符串。
▸ fromJSON(settings): void
从指定的 JSON 字符串加载对象状态。
| Name | Type | Description |
|---|---|---|
settings |
any |
从反序列化获取的单元格类型数据。 |
void
▸ getAutoFitHeight(value, text, cellStyle, zoomFactor, context?): number
获取一个单元格的高度,可以用于处理行自动适应。
| Name | Type | Description |
|---|---|---|
value |
any |
单元格的值。 |
text |
string |
单元格的文本。 |
cellStyle |
Style |
单元格的实际值。 |
zoomFactor |
number |
当前工作表的缩放因子。 |
context? |
any |
与单元格类型相关的上下文。 |
number
返回单元格的高度,可以用于处理行自动适应。
▸ getAutoFitWidth(value, text, cellStyle, zoomFactor, context?): number
获取一个单元格的宽度,可以用于处理列自动适应。
| Name | Type | Description |
|---|---|---|
value |
any |
单元格的值。 |
text |
string |
单元格的文本。 |
cellStyle |
Style |
单元格的实际值。 |
zoomFactor |
number |
当前工作表的缩放因子。 |
context? |
any |
与单元格类型相关的上下文。 |
number
返回单元格的宽度,可以用于处理列自动适应。
▸ getEditorValue(editorContext, context?): any
获取编辑器的值。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
context? |
any |
与单元格类型相关的上下文。 |
any
返回编辑器的值。
▸ getHitInfo(x, y, cellStyle, cellRect, context?): IHitTestCellTypeHitInfo
获取单元格类型的命中信息。
| Name | Type | Description |
|---|---|---|
x |
number |
指针当前位置相对于画布的 x 坐标。 |
y |
number |
指针当前位置相对于画布的 y 坐标。 |
cellStyle |
Style |
当前单元格的实际样式。 |
cellRect |
Rect |
当前单元格的布局信息。 |
context? |
any |
与单元格类型相关的上下文。 |
返回一个包含 x, y, row, col, cellRect 和 sheetArea 参数的对象,以及一个指示 isReservedLocation 的值。
isReservedLocation 为 true 表示命中测试在单元格类型需要处理的特殊区域;否则为 false。
▸ isEditingValueChanged(oldValue, newValue, context?): boolean
编辑值是否已更改。
| Name | Type | Description |
|---|---|---|
oldValue |
any |
旧的编辑值。 |
newValue |
any |
新的编辑值。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
boolean
如果 oldValue 等于 newValue,则返回 true;否则返回 false。
▸ isImeAware(context?): boolean
此单元格类型是否支持 IME。
| Name | Type | Description |
|---|---|---|
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
boolean
如果单元格类型支持 IME,则返回 true;否则返回 false。
▸ isReservedKey(e, context?): boolean
单元格类型是否自行处理键盘事件。
| Name | Type | Description |
|---|---|---|
e |
KeyboardEvent |
键盘事件。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
boolean
如果单元格类型自行处理键盘事件,则返回 true;否则返回 false。
▸ itemHeight(value?): any
获取或设置每个项目的身高。
example
// 此示例设置itemHeight方法。
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.items(["a","b","c"]);
cellType2.itemHeight(30);
activeSheet.getCell(2, 2).cellType(cellType2);
| Name | Type | Description |
|---|---|---|
value? |
number |
每个项目的身高。 |
any
如果未设置值,则返回复合框的每个项目的身高;否则返回复合框单元格类型。
▸ items(items?): any
获取或设置组合框下拉列表的项目。
example
// 此示例创建一个组合框单元格。
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.items(["a","b","c"]);
activeSheet.getCell(2, 2).cellType(cellType2);
| Name | Type | Description |
|---|---|---|
items? |
any[] |
组合框的项目。 |
any
如果未设置值,则返回项目数组;否则返回复合框单元格类型。
▸ maxDropDownItems(value?): any
获取或设置每页下拉列表的最大项目数。
example
// 此示例显示一次显示三个项目。
var cellType2 = new GC.Spread.Sheets.CellTypes.ComboBox();
cellType2.items(["a", "b", "c", "d", "e", "f", "g", "h"]);
cellType2.maxDropDownItems(3);
activeSheet.getCell(2, 2).cellType(cellType2);
});
| Name | Type | Description |
|---|---|---|
value? |
number |
每页下拉列表的最大项目数。 |
any
如果未设置值,则返回复合框每页下拉列表的最大项目数;否则返回复合框单元格类型。
▸ paint(ctx, value, x, y, w, h, style, context?): void
在画布上绘制单元格。
| Name | Type | Description |
|---|---|---|
ctx |
CanvasRenderingContext2D |
画布的二维上下文。 |
value |
any |
单元格的值。 |
x |
number |
相对于画布的 x 坐标。 |
y |
number |
相对于画布的 y 坐标。 |
w |
number |
单元格的宽度。 |
h |
number |
单元格的高度。 |
style |
Style |
单元格的实际样式。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
void
▸ paintContent(ctx, value, x, y, w, h, style, context?): void
在画布上绘制单元格内容区域。
| Name | Type | Description |
|---|---|---|
ctx |
CanvasRenderingContext2D |
画布的二维上下文。 |
value |
any |
单元格的值。 |
x |
number |
相对于画布的 x 坐标。 |
y |
number |
相对于画布的 y 坐标。 |
w |
number |
单元格内容区域的宽度。 |
h |
number |
单元格内容区域的高度。 |
style |
Style |
单元格的实际样式。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
void
▸ parse(text, formatStr, context?): any
使用指定的格式字符串将文本解析为对象。
| Name | Type | Description |
|---|---|---|
text |
string |
要解析的文本字符串。 |
formatStr |
string |
解析格式字符串。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
any
解析后的对象。
▸ processKeyDown(event, context?): boolean
在显示模式下处理按键按下事件。
| Name | Type | Description |
|---|---|---|
event |
KeyboardEvent |
键盘事件。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processKeyUp(event, context?): boolean
在显示模式下处理按键释放事件。
| Name | Type | Description |
|---|---|---|
event |
KeyboardEvent |
键盘事件。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processMouseDown(hitInfo): boolean
在显示模式下处理鼠标按下事件。
| Name | Type | Description |
|---|---|---|
hitInfo |
IHitTestCellTypeHitInfo |
由 getHitInfo 方法返回的命中测试信息。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processMouseEnter(hitInfo): boolean
在显示模式下处理鼠标进入事件。
| Name | Type | Description |
|---|---|---|
hitInfo |
IHitTestCellTypeHitInfo |
由 getHitInfo 方法返回的命中测试信息。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processMouseLeave(hitInfo): boolean
在显示模式下处理鼠标离开事件。
| Name | Type | Description |
|---|---|---|
hitInfo |
IHitTestCellTypeHitInfo |
由 getHitInfo 方法返回的命中测试信息。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processMouseMove(hitInfo): boolean
在显示模式下处理鼠标移动事件。
| Name | Type | Description |
|---|---|---|
hitInfo |
IHitTestCellTypeHitInfo |
由 getHitInfo 方法返回的命中测试信息。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ processMouseUp(hitInfo): boolean
在显示模式下处理鼠标释放事件。
| Name | Type | Description |
|---|---|---|
hitInfo |
IHitTestCellTypeHitInfo |
由 getHitInfo 方法返回的命中测试信息。有关更多信息,请参阅备注。 |
boolean
如果处理成功则返回 true;否则返回 false。
▸ selectAll(editorContext, context?): void
选择编辑器 DOM 元素中的所有文本。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
void
▸ setEditorValue(editorContext, value, context?): void
设置编辑器的值。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
value |
any |
由活动单元格返回的值。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
void
▸ toJSON(): any
将对象状态保存为 JSON 字符串。
any
单元格类型数据。
▸ updateEditor(editorContext, cellStyle, cellRect, context?): Rect
更新编辑器的大小。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
cellStyle |
Style |
单元格的实际样式。 |
cellRect |
Rect |
单元格的布局信息。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
返回单元格包装元素的新大小,它应包含 'width' 和 'height' 两个属性。
▸ updateEditorContainer(editorContext, editorBounds, cellStyle): void
更新单元格包装元素的大小。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
editorBounds |
Rect |
单元格包装元素的新大小。 |
cellStyle |
Style |
单元格的实际样式。 |
void
▸ updateImeMode(editorContext, imeMode, context?): void
更新编辑器的输入法模式。
| Name | Type | Description |
|---|---|---|
editorContext |
HTMLElement |
由 createEditorElement 方法创建的 DOM 元素。 |
imeMode |
ImeMode |
来自单元格实际样式的输入法模式。 |
context? |
any |
与单元格类型相关的上下文。有关更多信息,请参阅备注。 |
void