cancel
Showing results for 
Search instead for 
Did you mean: 

m Table not refresh after sort order changed in model

janithi
Participant
0 Kudos

Hi.
I'm implementing a sort functionality in m Table according to the following sample

Drag and Drop 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?

Accepted Solutions (0)

Answers (1)

Answers (1)

janithi
Participant
0 Kudos

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" >