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

[Feature] 通过column.field控制冻结列 #1934

Open
fourteendp opened this issue Jun 17, 2024 · 1 comment
Open

[Feature] 通过column.field控制冻结列 #1934

fourteendp opened this issue Jun 17, 2024 · 1 comment
Labels
feature 新需求 good first issue Good for newcomers

Comments

@fourteendp
Copy link

What problem does this feature solve?

方便外部控制冻结列

What does the proposed API look like?

以下个人业务中实现

  frozenColConfig?: {
    leftField: string;
    rightField: string;
  };
export const columnsToList = (
  columns: VTableOptions['columns'],
  parentField?: string,
): VTableOptions['columns'] => {
  const result: VTableOptions['columns'] = [];
  cloneDeep(columns!).forEach((column) => {
    if (column.columns && column.columns.length) {
      result.push(
        ...(columnsToList(
          column.columns,
          parentField ? `${parentField}.${column.field}` : column.field,
        ) ?? []),
      );
    } else {
      if (parentField) {
        column.field = `${parentField}.${column.field}`;
      }
      result.push(column);
    }
  });
  return result;
};

export const getFrozenColCount = (
  options: VTableOptions,
  columns: VTableOptions['columns'],
  frozenColCount = 0,
  rightFrozenColCount = 0,
): {
  frozenColCount: number;
  rightFrozenColCount: number;
} => {
  const { leftField = 'isCheck', rightField = '' } = options.frozenColConfig ?? {};
  const columnsList = columnsToList(columns ?? []);

  const leftFrozenColCount = columnsList!.findIndex((column) => column.field === leftField) + 1;
  const _rightFrozenColCount =
    columnsList!.reverse().findIndex((column) => column.field === rightField) + 1;
  if (leftFrozenColCount !== -1) {
    frozenColCount += leftFrozenColCount;
  }
  if (rightFrozenColCount !== -1) {
    rightFrozenColCount += _rightFrozenColCount;
  }

  return {
    frozenColCount,
    rightFrozenColCount,
  };
};
@fourteendp fourteendp added the feature 新需求 label Jun 17, 2024
@fangsmile
Copy link
Contributor

收到。可能最近没有时间安排这个需求。
可以暂时使用frozenColCount来实现 。 调整好columns中的顺序 需要冻结的放到前面

@fangsmile fangsmile added the good first issue Good for newcomers label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 新需求 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants