I believe we found the solution for this problem.
Issue was with _onFetchBegin method of Dojo’s DataGrid.
When we call sort on DataGrid it actually clears some counters by calling updateRowCount(0).
One of the counters that is cleared is this.invalidated.rowCount which is actually used by DataGrid and dojo to print the records. The number of printed records is equal to this.invalidated.rowCount value.
Later, during the grid.sort() call processing, dojo goes to the _fetch(0, isRender); method. This method eventually calls this.store.fetch({…}) which updates the grid based on items returned from store. It is done by callback methods _onFetchBegin and _onFetchComplete. The problem was in _onFetchBegin
In our case the number of items returned from store was equal to the number row in grid. if(this.rowCount != size) <–this is false. Mind that we dont use this.invalidated.rowCount here but this.rowCount. this.invalidated.rowCount was set to 0 in updateRowCount(0) previously. Normally, when this condition would be true we would call this.updateRowCount(size); where size is the number of items in the store. And dojo would print the grid with rows. But in our case, this.rowCount and size was the same (we add on record, and remove one record) so we ended up couple lines further in DataGrid
if(!size){
this.views.render();
this._resize();
this.showMessage(this.noDataMessage);
this.focus.initFocusView();
}else{
this.showMessage(); <- we ended up here. And we we do not update the RowCount :(
}
If we add this.updateRowCount(size); before this.showMessage();