Skip to content

是否可以提供"radioConfig.canCheckRadioAsync"异步方法 #2859

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

Open
1 task done
WJjack opened this issue Apr 7, 2025 · 2 comments
Open
1 task done

是否可以提供"radioConfig.canCheckRadioAsync"异步方法 #2859

WJjack opened this issue Apr 7, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@WJjack
Copy link

WJjack commented Apr 7, 2025

这个需求解决了什么问题:

当单击某行切换单选选中更新选中值前,我需要弹出弹窗提示用户是否要切换行选中,我需要做异步,当异步返回true,则更改单选值切换行,否则不更改,如下:

建议的 API 是什么样的:

// 类型定义
type canCheckRadioAsync = (params: { row: Row }) => Promise<boolean>
// 方法定义
const canCheckRadioAsync: async ({ row }) => {
  return new Promise((resolve, reject) => {
    // 弹出弹窗
    AModal.confirm({
      title: '表单数据未保存,是否切换选中行?',
      onOk: async () => {
        await save(); // 保存数据
        resolve(true) // 允许切换行选中
      },
      onCancel: () => {
        resolve(false); // 不切换行选中
      }
    });
  });
}

// vxe-table内部更改单选值前调用该方法
const can = await canCheckRadioAsync();
if (can) // vxe-table内部更改单选选中的值
else // vxe-table内部不更改单选选中值

是否已有其他不错的替代方案:

暂无

是否使用当前最新版本?

  • 我已确认是使用当前的最新版本。
@WJjack WJjack added the enhancement New feature or request label Apr 7, 2025
@xlz26296
Copy link
Contributor

xlz26296 commented Apr 10, 2025

文档有 beforeSelectMethod 可以实现,也可以异步自定义实现

@WJjack
Copy link
Author

WJjack commented Apr 11, 2025

但是beforeSelectMethod是同步的,我需要异步的实现方式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants