Applying loader in table before noDataText display and after page change
See original GitHub issueHi, I have two problems after adding a loader to the table. 1- If there are no data to display, noDataText is not displayed and the loader remains displayed. 2- When changing pages, the loader is not displayed during data loading. My skeleton code is as follows:
class PaginationTable extends Component {
constructor(props) {
super(props);
this.state = {
items:[],
totalSize: 0,
page: 1,
sizePerPage: 10,
isDataFetched: false,
};
this.fetchData = this.fetchData.bind(this);
this.handlePageChange = this.handlePageChange.bind(this);
this.handleSizePerPageChange = this.handleSizePerPageChange.bind(this);
this.setTableOption = this.setTableOption.bind(this);
this.options = {
onPageChange: this.handlePageChange,
onSizePerPageList: this.handleSizePerPageChange,
page: this.state.page,
sizePerPage: this.state.sizePerPage,
paginationShowsTotal: this.renderShowsTotal,
pageStartIndex: 1,
noDataText: this.setTableOption()
}
}
fetchData(page = this.state.page, sizePerPage = this.state.sizePerPage) { const params = {page : page, sizePerPage: sizePerPage };
const urlParams = new URLSearchParams(Object.entries(params));
let me = this;
fetch("http://localhost:17080/comment-list?" + urlParams)
.then(
function(response) {
if (response.status !== 200) {
return;
}
response.json().then(function(data) {
me.setState({items: data.items, totalSize: data.total, page, sizePerPage, isDataFetched: true});
});
}
)
.catch(function(err) {
me.setState({isDataFetched: true});
console.log("Fetch Error :-S", err);
});
}
componentDidMount() {
this.fetchData();
}
handlePageChange(page, sizePerPage) {
this.setState({
isDataFetched:false,
});
this.fetchData(page, sizePerPage);
}
handleSizePerPageChange(sizePerPage) {
this.fetchData(1, sizePerPage);
}
renderShowsTotal(start, to, total) {
return (
<p>
Liste des commentaire de { start } à { to } sur un total de { total }
</p>
);
}
setTableOption(){
if(this.state.isDataFetched){
return "No data";
}else{
return(
<Loadable
active={true}
spinner
text="Loading..."
background="#e7e7e7"
color="#5e5e5e"
style={{height:"350px"}}
>
</Loadable>
);
}
}
render() {
return (
<div className="container">
<BootstrapTable
data={this.state.items}
fetchInfo={{dataTotalSize: this.state.totalSize}}
pagination
options={this.options}
striped
remote
height="100%"
>
<TableHeaderColumn
dataField="text"
dataAlign="center"
dataSort
tdStyle={{ "word-wrap": "break-word", "white-space": "normal", "vertical-align": "middle" }}
>
Commentaire
</TableHeaderColumn>
</BootstrapTable>
</div>
);
}
}
My question is, is it possible to display the loader then the noTextData if there is no data and is it possible to display the loader between the change of pages. And how to do that. I would be grateful if you could give me a solution to this.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to show Page Loading div until the page has finished ...
Original Answer. I've needed this and after some research I came up with this (jQuery needed):. First, right after the <body> tag add...
Read more >Best way to display loading time when data table is updated
You can just make a small animation on the table data/cell whenever some change has been applied. A quick fade or flash before...
Read more >Data table control in Power Apps - Microsoft Learn
NoDataText – The message that the user receives when there are no records to show in the Data table control. Order - The...
Read more >JavaScript Data Grid Configuration - DevExtreme - DevExpress
Use this property when you display the component on a platform whose guidelines include the active state change for UI components.
Read more >Responsive Table | SAP Fiori Design Guidelines
One data point is usually displayed by a control, such as a text, ... the responsive table just minimizes all visible columns until...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Set your options like this:
And add in a timed spinner component like this:
@AllenFang how can i add
noDataText: 'Loading...'+<i className="fa fa-spinner fa-spin" />
the above display as
Loading...[object Object]