Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: supplement apis #3232

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion docs/assets/api/en/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ If it is a table in tree mode, an array will be returned, such as [1,2], the 3rd
**ListTable proprietary**
```

## getTaskShowIndexByRecordIndex(Function)
## getBodyRowIndexByRecordIndex(Function)

Get the row number that should be displayed in the body according to the index of the data. Both the parameter and the return value start from 0. If it is a table in tree mode, the parameter supports arrays, such as [1,2]

Expand Down Expand Up @@ -543,6 +543,29 @@ Get the specific position of the cell in the entire table. Relative position is
getCellRelativeRect(col: number, row: number): Rect
```

## getCellRange(Function)

Gets the merge range for the cell

```
/**
* @param {number} col column index
* @param {number} row row index
* @returns {Rect}
*/
getCellRange(col: number, row: number): CellRange

export interface CellRange {
start: CellAddress;
end: CellAddress;
}

export interface CellAddress {
col: number;
row: number;
}
```

## getCellHeaderPaths(Function)

Get the path to the row list header
Expand Down Expand Up @@ -1328,3 +1351,14 @@ Set the loading state of the tree expansion and collapse of the cell
/** Set the loading state of the tree expansion and collapse of the cell */
setLoadingHierarchyState: (col: number, row: number) => void;
```

## setPixelRatio(Function)

Sets the pixel ratio of the canvas. The default internal logic is window.devicePixelRatio. If the drawing feels fuzzy, try setting this value higher.

The pixelRatio can be obtained directly from the instance's pixelRatio property.

```
/** Set the canvas pixel ratio */
setPixelRatio: (pixelRatio: number) => void;
```
6 changes: 5 additions & 1 deletion docs/assets/api/en/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ Horizontal scroll bar position

## scrollTop

Vertical scroll bar position
Vertical scroll bar position

## pixelRatio

Canvas pixel ratio
36 changes: 35 additions & 1 deletion docs/assets/api/zh/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ setRecords(records: Array<any>)
**ListTable 专有**
```

## getTaskShowIndexByRecordIndex(Function)
## getBodyRowIndexByRecordIndex(Function)

根据数据的索引获取应该显示在 body 的第几行, 参数和返回值的碎银均从 0 开始。如果是树形模式的表格,参数支持数组,如[1,2]

Expand Down Expand Up @@ -539,6 +539,29 @@ setRecords(records: Array<any>)
getCellRelativeRect(col: number, row: number): Rect
```

## getCellRange(Function)

获取单元格的合并范围

```
/**
* @param {number} col column index
* @param {number} row row index
* @returns {Rect}
*/
getCellRange(col: number, row: number): CellRange

export interface CellRange {
start: CellAddress;
end: CellAddress;
}

export interface CellAddress {
col: number;
row: number;
}
```

## getCellHeaderPaths(Function)

获取行列表头的路径
Expand Down Expand Up @@ -1326,3 +1349,14 @@ interface ISortedMapItem {
/** 设置单元格的树形展开收起状态为 loading */
setLoadingHierarchyState: (col: number, row: number) => void;
```

## setPixelRatio(Function)

设置画布的像素比,内部逻辑默认值为 window.devicePixelRatio 。如果感觉绘制内容模糊,可以尝试将这个值设置高一点。

获取 pixelRatio 画布像素比可以直接通过实例的 pixelRatio 属性获取。

```
/** 设置画布的像素比 */
setPixelRatio: (pixelRatio: number) => void;
```
6 changes: 5 additions & 1 deletion docs/assets/api/zh/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Properties

表格实例的属性列表,以下列出的都有getter 部分有setter
表格实例的属性列表,以下列出的都有 getter 部分有 setter

## records

Expand Down Expand Up @@ -85,3 +85,7 @@
## scrollTop

纵向滚动条位置

## pixelRatio

画布像素比
5 changes: 4 additions & 1 deletion packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,9 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
const limits = this._getColWidthLimits(col);
return Math.max(_applyColWidthLimits(limits, orgWidth), 0);
}

get pixelRatio(): number {
return this.internalProps.pixelRatio;
}
/**
* 设置像数比
* @param pixelRatio
Expand All @@ -943,6 +945,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
this.scenegraph.setPixelRatio(pixelRatio);
}
}

/**
* 窗口尺寸发生变化 或者像数比变化
* @return {void}
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ export interface BaseTableAPI {
_colRangeWidthsMap: Map<string, number>;
canvasSizeSeted?: boolean;

pixelRatio: number;

/** 获取表格绘制的范围 不包括frame的宽度 */
getDrawRange: () => Rect;
/** 将鼠标坐标值 转换成表格坐标系中的坐标位置 */
Expand Down
Loading