‎2017 Feb 02 4:56 PM - edited ‎2024 Jan 21 9:35 PM
Hello everybody,
I have a server query with 70,000 records. This takes about 6 seconds. This data I insert into a m.Table.
My question is now, if I only want to display the first 100 records and only by scrolling another 100, I still have to load the complete data set (70,000) before? Or is it possible to query the files from the server only when scrolling?
Best regards
Yannick
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! I have never worked with oData, so I still have some problems.
So I load all the data from the server. What do I have to do? I guess I need to change something in the XML view.
<List
id="test"
items ="{
path: 'employees>/'}"
headerText="Employees"
growing="true"
growingThreshold="4"
growingScrollToLoad="true">
<StandardListItem
title="{employees>USERID}"
/>
</List>
onInit : function() {
var oModel = new sap.ui.model.odata.ODataModel("EmployeeODataService.xsodata/", true);
var jsonModel = new sap.ui.model.json.JSONModel();
oModel.read("/Employee",null,null,true,function(oData,response){
jsonModel.setData(oData.results)
})
this.getView().setModel(jsonModel, "employees");
}
We could use $top & $skip approach.
onInit: function () {
var oModel = new sap.ui.model.odata.v2.ODataModel("EmployeeODataService.xsodata/", true);
oModel.read("/Employee?$top=5", null,null,true, function(oData){
var jsonModel = new sap.ui.model.json.JSONModel();
jsonModel.setData(oData);
this.getView().setModel(jsonModel, "employees");
}.bind(this));
}var oModel = sap.ui.getCore().getModel();
oModel.read("/Employee?$top=5&skip="+fetchedRecords, null,null,true, function(oData){
var oTableModel = this.getView().getModel("employees"); //Get your table model
var aTableData = oTableModel.getProperty("/modelData/data"); // Get entries
aTableData.push.apply(aTableData, aData); // Add more entries
oTableModel.setProperty("/modelData/data", aTableData); // // Update model
}.bind(this));Note: I haven't tested this approach. I have seen people using $top & $skip approach in paginations. However, I feel that we can use this for growing table as well.
Thank you very much! I've changed it to this:
onInit : function() {
var oModel = new sap.ui.model.odata.ODataModel("EmployeeODataService.xsodata/", true);
var jsonModel = new sap.ui.model.json.JSONModel();
oModel.read("/Employee?$top=50",null,null,true,function(oData,response){
jsonModel.setData(oData.results)
this.getView().setModel(jsonModel, "employees");
fetchedRecords = fetchedRecords + 50;
}.bind(this));
},
grow : function() {
var oModel = new sap.ui.model.odata.ODataModel("EmployeeODataService.xsodata/", true);
oModel.read("/Employee?$skip="+fetchedRecords+"&$top=50", null,null,true, function(oData){
var oTableModel = this.getView().getModel("employees"); //Get your table model
var aTableData = oTableModel.getData(); // Get entries
aTableData.push.apply(aTableData, oData.results); // Add more entries
oTableModel.setData(aTableData); // // Update model
fetchedRecords = fetchedRecords + 50;
}.bind(this));
}
<br>
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.