on 2015 Mar 24 7:09 PM
Hello colleagues,
please advise.
I'm trying to have a simple sorting by column value.
1. The table is created like this:
var oTable = new sap.ui.table.Table({
id: "Overview",
title : "Table1",
});
2. Then I add a column:
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text : "Column1"}),
template : new sap.ui.commons.TextView().bindProperty("text","SENDER_NAME"),
sortProperty : "SENDER_NAME",
filterProperty : "SENDER_NAME",
}));
3. Assign oData model:
oTable.setModel(oController.oModel);
4. Create Sorter:
var sort1 = new sap.ui.model.Sorter("P8_TOTAL");
5.Bind rows of Model to oTable
oTable.bindRows("/DASHBOARDSet",sort1);
6.Return table to View
return oTable;
Seems like piece a cake, but it is not working.
No idea why. I've read many threads here and couldn't make it work.
Appreciate your help.
Thank you.
Request clarification before answering.
Alex, SAP just came up with client side sorting/filtering for OData model in 1.28:
The first steps towards client-side filtering/sorting on OData Model Data: the final implementation is planned for a later release, but a first experimentalversion is available in 1.28: by setting the “OperationMode" on a list binding to "Client", you can force the OData model to loadall data from the server and do sorting and filtering entirely in the browser, with no server roundtrip. Useful only when it is guaranteed that the count of data elements is low.
So, if you need client side sorting/filtering - use JsonModel as suggested before
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.
Hello Alexander,
What behavior are you exactly observing?
When the data is rendered in the table, by default the sorting would be applied on 'P8_TOTAL'.
When you sort on the Column that you have added, there should be a call to the backend for sorting on SENDER_NAME ($orderby = SENDER_NAME asc)
Regards
Radhika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
i'm using this code, Replace ur oData Model to this,
$.ajax({ |
url : YOUR_URL, | |||||
jsonpCallback : 'getJSON', | |||||
contentType : "application/json", | |||||
dataType : 'json', | |||||
success : function(data, textStatus, jqXHR) | |||||
{ | |||||
var oModel1 = new sap.ui.model.json.JSONModel(); | |||||
oModel1.setData(data); | |||||
var aData = oModel1.getProperty("/d/results"); | |||||
oModel1.setData({ modelData : aData }); | |||||
table.setModel(oModel1, "odata"); | |||||
table.bindAggregation("items","odata>/modelData", that); | |||||
// |
}, | ||||
}); |
Here is just one of the way, adjust accordingly. Success call back function parameter has results variable which contains a data from OData call, so just slice and dice it, or just copy as is
new sap.ui.model.json.JSONModel(oEvent.results)
try {
oModel.read("/StatusSet", null, null, true, function(oEvent) {
var map = [];
var list = [];
$.each(oEvent.results, function(i, item) {
list.push({
"Status" : item.StatusNum,
"Description" : item.Description
});
map[item.StatusNum] = item.Description;
});
var jModel = new sap.ui.model.json.JSONModel({
"map" : map,
"list" : list
});
sap.ui.getCore().setModel(jModel, "StatusModel");
sap.ui.getCore().getEventBus().publish("app", "StatusModelLoaded");
}, function(oError) {
jQuery.sap.log.error("An error occurred while processing StatusSet");
});
} catch (oError) {
jQuery.sap.log.error("An error occurred while processing StatusSet");
}
User | Count |
---|---|
66 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.