on 02-21-2019 11:02 AM
Hi.
I'm implementing a sort functionality in m Table according to the following sample
And as I altered the sample code as per my situation it will be as follows
moveSelectedItem: function (sDirection) {
var oSelectedProductsTable = this.getView().byId("defectsTable");this.getSelectedItemContext(oSelectedProductsTable, function (oSelecte dItemContext, iSelectedItemIndex) {
var iSiblingItemIndex = iSelectedItemIndex + (sDirection === "Up" ? -1 : 1);
var oSiblingItem = oSelectedProductsTable.getItems()[iSiblingItemIndex];
var oSiblingItemContext = oSiblingItem.getBindingContext();
if (!oSiblingItemContext) {
return;
}
// swap the selected and the siblings rank
var oProductsModel = oSelectedProductsTable.getModel();
var iSiblingItemRank = oSiblingItemContext.getProperty("SEQUENCE");
var iSelectedItemRank = oSelectedItemContext.getProperty("SEQUENCE");
oProductsModel.setProperty("SEQUENCE", iSiblingItemRank, oSelectedItemContext);
oProductsModel.setProperty("SEQUENCE", iSelectedItemRank, oSiblingItemContext);
// after move select the sibling
oSelectedProductsTable.getItems()[iSiblingItemIndex].setSelected(true);
});
},
getSelectedItemContext: function (oTable, fnCallback) {
var aSelectedItems = oTable.getSelectedItems();
var oSelectedItem = aSelectedItems[0];
if (!oSelectedItem) {
MessageToast.show("Please select a row!");
return;
}
var oSelectedContext = oSelectedItem.getBindingContext();
if (oSelectedContext && fnCallback) {
var iSelectedIndex = oTable.indexOfItem(oSelectedItem);
fnCallback(oSelectedContext, iSelectedIndex, oTable);
}
return oSelectedContext;
},
moveUp: function () {
this.moveSelectedItem("Up");
},
moveDown: function () {
this.moveSelectedItem("Down");
},
I debugged and checked that the SEQUENCE property of the model is updating correctly.
But table sort order is not changing by the updated SEQUENCE value.
What will be the issue?
It worked when I set the growing property to - true
<Table id="defectsTable" growing="true" growingThreshold="10" items="{ path : '/Defects' ,sorter: {path: 'SEQUENCE'}}" mode="SingleSelectMaster" >
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.