Skip to Content

m Table not refresh after sort order changed in model

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) {

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

getSelectedItemContext: function (oTable, fnCallback) {
	var aSelectedItems = oTable.getSelectedItems();
	var oSelectedItem = aSelectedItems[0];

	if (!oSelectedItem) {"Please select a row!");

	var oSelectedContext = oSelectedItem.getBindingContext();
	if (oSelectedContext && fnCallback) {
		var iSelectedIndex = oTable.indexOfItem(oSelectedItem);
		fnCallback(oSelectedContext, iSelectedIndex, oTable);

	return oSelectedContext;

moveUp: function () {

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Feb 21, 2019 at 11:43 AM

    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" >
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.