02-02-2017 4:56 PM - edited 01-21-2024 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
A user is going to spend time scrolling through 70,000 records? I think they should get a medal for patience. My best suggestion would be to review the business process instead of trying to handle it in code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.