alibaba / alibaba/lowcode-engine

组件库拖入画布后设置器无法动态设置初始化数据问题

Open
#1,624 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

## **详细描述**

有个需求是当组件库拖入一个ProTable后,通过请求的加载来动态初始化一份‘表格列’数据,并通过现有的设置器功能进行简单的删除和编辑达到减少操作员对表格列数据的工作量

因此使用了如下代码进行处理

```ts
import { material } from '@alilc/lowcode-engine';
import { IPublicModelNode } from '@alilc/lowcode-types';

material.addBuiltinComponentAction({
name: 'myIconName',
content: {
icon: () => 'Ⅰ',
title: '数据帮助加载',
action(node: IPublicModelNode) {
// 异步加载数据后设置到表格列
const columns = [
{ title: 'ID', dataIndex: 'id', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '名称1', dataIndex: 'nickname', valueType: 'text' },
{ title: '头像', dataIndex: 'avatar', valueType: 'avatar' },
]
node.setPropValue('columns', columns)
}
},
important: true,
condition: (currentNode: IPublicModelNode) => {
return ['ProTable'].includes(currentNode.componentName);
},
});
```
看了所有文档api并没有办法做到想要的功能,只有看到IPublicModelNode上提供了setPropValue的方法,虽然渲染结果变了但达不到和setters设置器进行联动的效果看如下截图。如果我遗漏了什么api能实现或者这种思路是错误的,麻烦给我一个思路 谢谢!

## **Screenshots (optional)** / ** 截图 **

![image](https://user-images.githubusercontent.com/20472494/220551722-12532b9e-bd68-4382-9dd1-12719126ee9b.png)

## **Environments (please complete the following information) (required):** / **请提供如下信息(必填)**
- AliLowCodeEngine version: [e.g. 1.1.2] / 低代码引擎版本
- AliLowCodeEngineExt version: [e.g. 1.0.5] / 低代码引擎扩展包版本
- Browser chrome / 浏览器版本

> (this information can be collected via [the manual plugin](https://img.alicdn.com/imgextra/i1/O1CN0115zonY1IsgbkZ2ir7_!!6000000000949-2-tps-3066-1650.png) / 版本信息可[通过低代码用户手册插件收集](https://img.alicdn.com/imgextra/i1/O1CN0115zonY1IsgbkZ2ir7_!!6000000000949-2-tps-3066-1650.png))

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the ProTable action registered through material.addBuiltinComponentAction and trace IPublicModelNode.setPropValue alongside the setters behavior. Check how the current node property update is propagated to the setter UI; done means asynchronously loaded columns update both the rendered table and the existing setters state.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.