Setting a default sorting order for Table inner edit window

Hi

I have problem with set default sorting order for table. I create code like this in editwindow controller. I see then problem is in user settings. When I set settingsEnabled=false this code working rightly. Is there any way don’t save table sorting order in user settings?

public void init(Map<String, Object> params) {
	// TODO Auto-generated method stub
	super.init(params);
	baseEditor = new BaseEditor();
	baseEditor.init(getComponents(), params, getDsContext());
	insert_mode = baseEditor.isInsertMode((Entity<?>) params.get("ITEM"));
	accessoriesTable.sort("rownumber", Table.SortDirection.ASCENDING);
	
	accessoriesDs.addCollectionChangeListener(e -> {
		int counter = 0;
		ArrayList<Accessories> lines = new ArrayList<>(accessoriesDs.getItems());
		lines.sort(Comparator.comparingInt(Accessories::getId));
		for (Accessories acc : lines) {
			acc.setRowNumber(++counter);
		}
		((DatasourceImplementation<Accessories>) accessoriesDs).setModified(false);
	});
}

Hello @andrzej.paluch72

I’m sorry for waiting.

The easiest way is to disable user settings for the table with settingsEnabled attribute (see docs: link).

User settings have the highest priority and will allways override behavior described in code.

Regards,
Daniil.

Thanks for reply.

Finally I overwrite saveSettings method and set order like this code

Table table = tableList.get("tablename");
table.sort("rownumber", Table.SortDirection.ASCENDING);
1 Like