大家好,我想使用反跳方法进行服务器端搜索,当我在表中创建ref
并将其记录下来时,我发现了此方法onSearchChangeDebounce
,但我不知道如何使用它,任何想法,我将不胜感激。
这是我的代码
<MaterialTable
tableRef={ref => this.tableRef = ref}
title={title}
data={data}
isLoading={store.loading}
options={this.options}
actions={this.actions}
localization={this.localization}
columns={this.columns}
components={this.components}
icons={this.icons}
detailPanel={this.rowDetailsPanel}
onChangeRowsPerPage={pageSize => this.handleChangePageSize(pageSize)}
onSearchChange={data => this.handleServerSideSearch(data)}
/>
handleServerSideSearch(dataToSearch) {
console.log(dataToSearch);
// call api here after debounce
}
谢谢。
答案 0 :(得分:1)
您可以使用input: "This// is //text"
output: "This/ is /text"
道具在以下选项中设置去抖动间隔:
debounceInterval
这将在上一次用户搜索互动1秒后调用<MaterialTable
tableRef={ref => this.tableRef = ref}
title={title}
data={data}
isLoading={store.loading}
options={{...this.options, debounceInterval: 1000}}
actions={this.actions}
localization={this.localization}
columns={this.columns}
components={this.components}
icons={this.icons}
detailPanel={this.rowDetailsPanel}
onChangeRowsPerPage={pageSize => this.handleChangePageSize(pageSize)}
onSearchChange={data => this.handleServerSideSearch(data)}
/>
handleServerSideSearch(dataToSearch) {
console.log(dataToSearch);
// call api here after debounce
}
。