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

As long as in the asynchronous code, _table. ReloadData(); Why doesn't it take effect? #3809

Open
icetech233 opened this issue Apr 22, 2024 · 10 comments

Comments

@icetech233
Copy link

icetech233 commented Apr 22, 2024

	<Modal Keyboard=false MaskClosable=false
       @bind-Visible=@ModalVisible Footer=@null AfterClose=@AfterCloseHandle>
    <TitleTemplate>
	

@ref=_table

    private async void OnFinishHandle(EditContext editContext)
    {
        ModalVisible = false;
        await PostAuditAsync();
    }


        private async Task PostAuditAsync()
        {
            try
            {
                BaseResp resp = await BizSrv.AuditStockInAsync(auditModel);
                if (resp.Code == 200)
                {
                    _message.Success("操作成功", 3);
                    await Task.Run(async () => 
                    {
                        StockInListResp stockInResp = await BizSrv.GetStockInListAsync();
                        stockInList = stockInResp.Data.OrderByDescending(a => a.StockInID).ToList();
                        _table.ReloadData();
                    });
                }
                else
                {
                    _message.Error("操作失败:" + resp.Msg, 3);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
@icetech233
Copy link
Author

_table.ReloadData(); 加了 也没有用, 强制刷新是用哪个函数

@stfei
Copy link

stfei commented Apr 23, 2024

是不是表格没有OnChange事件刷新不了吧?刷新会触发这个事件
参考https://antblazor.com/zh-CN/components/table#components-table-demo-ajax

@ElderJames ElderJames changed the title 只要在异步代码中, _table.ReloadData(); 不生效是为啥呢 As long as in the asynchronous code, _table. ReloadData(); Why doesn't it take effect? Apr 24, 2024
@icetech233
Copy link
Author

是不是表格没有OnChange事件刷新不了吧?刷新会触发这个事件 参考https://antblazor.com/zh-CN/components/table#components-table-demo-ajax

函数,单独执行是可以的,只要不是和modal 混在 一起就没有任何问题, modal visiable 改变 和table 不知道哪里冲突了,

@icetech233
Copy link
Author

我的猜测是 modal 影藏的阻塞了, table的刷新, 元素是变了, 但是UI不刷新

@ElderJames
Copy link
Member

Hello @icetech233 , please provide the complete duplicate code.

@stfei
Copy link

stfei commented Apr 28, 2024

w

是不是表格没有OnChange事件刷新不了吧?刷新会触发这个事件 参考 https://antblazor.com/zh-CN/components/table#components-table-demo-ajax

函数,单独执行是可以的,只要不是和模态混在 一起就没有任何问题, modal visiable 改变 和table 不知道哪里冲突了,

我一般就是加入了OnChange实现函数中调用StateHasChanged();就可以

@icetech233
Copy link
Author

w

是不是表格没有OnChange事件刷新不了吧?刷新会触发这个事件 参考 https://antblazor.com/zh-CN/components/table#components-table-demo-ajax

函数,单独执行是可以的,只要不是和模态混在 一起就没有任何问题, modal visiable 改变 和table 不知道哪里冲突了,

我一般就是加入了OnChange实现函数中调用StateHasChanged();就可以

数据有刷新,不生效而已

@GoldSucc
Copy link

GoldSucc commented May 13, 2024

@icetech233 You should use Interactive render mode for interactive pages, otherwise it will not be changed. You can use @rendermode InteractiveServer for this (or wasm/auto alternative, depends on your project)

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

No branches or pull requests

4 participants