Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Change no data text for Search in SAPUI5
You just need to use the noDataText property to sort out your requirement. This property allows you to customize the message displayed when a search returns no results or when a list/table has no data to show.
You have two options, either you can change in controller or you can change in the XML.
Option 1: Using Controller Method
Call the setNoDataText method in the init method of your controller ?
this.byId("<Your Id>").setNoDataText("<Your custom text>")
Complete Example
Here's a complete example showing how to implement this in a controller ?
onInit: function() {
// Set custom no data text for search results
this.byId("searchResultsList").setNoDataText("No results found. Please try a different search term.");
// You can also set it for tables
this.byId("dataTable").setNoDataText("No data available to display.");
}
Option 2: Using XML View
Add the noDataText property directly in the XML view ?
<List noDataText="No search results found" />
Complete XML Example
Here's how you can implement it in a complete XML view ?
<List id="searchResultsList"
noDataText="No results match your search criteria"
items="{/SearchResults}">
<StandardListItem title="{Title}" description="{Description}" />
</List>
<Table id="dataTable"
noDataText="No data available in the system"
items="{/TableData}">
<columns>
<Column>
<Text text="Name" />
</Column>
</columns>
</Table>
Conclusion
Both approaches allow you to customize the no data message effectively. Use the controller method for dynamic text changes and the XML property for static messages that don't need to change at runtime.
