cancel
Showing results for 
Search instead for 
Did you mean: 

Flexible Programming Model - Disable Column Resizing / Reordering by User?

axel_brke3
Participant
0 Kudos
214

Hi,

Using the Flexible Programming Model Table in SAP UI 1.108, I cannot see an option in the API to disable manual resizing of Columns by the user. We would like to disable it.

Im talking about the users ability to drag a column when clocking on the seperation line or column header

axel_brke3_0-1738751359263.png

Main reason ist that the responsive layout doesnt work properly anymore once the User resized a column.

What striked me as well that this is even possible with disabled Table Personalisation. This makes it impossible for the user to return to default if he resized the column

Accepted Solutions (1)

Accepted Solutions (1)

axel_brke3
Participant
0 Kudos

I solved this on 108 using

 
var oTable = this.getView().byId("rwws.eh.feprototype.owbfe::ScaleReceiptSetMain--LineItemTable-content");
oTable.setEnableColumnResize(false);
 
I am not very happy with this approach

For later versions, Marian's response should be applied as it's a more elegant approach

Marian_Zeis
Active Contributor

please edit to not use "sap.ui.getCore" and more like "this.base.getView()" or something like that. "sap.ui.getCore" will be deprecated in UI5 2.0. But this is also a valiid approach, i do think this will work for a long time

i just used it because i executed it in the console and not in code

axel_brke3
Participant
Thanks for this, I was lazy here. Edited my response

Answers (1)

Answers (1)

Marian_Zeis
Active Contributor

 A bit disappointing that this is possible with sap.ui.mdc.Table but not with macros.Table.
But it is possible and that even without private APIs, you just have to start from the inner sap.m.Table

sap.m.plugins.ColumnResizer.findOn(sap.ui.getCore().byId("sap.fe.core.fpmExplorer.tableDefault::Default--LineItemTable-content-innerTable")).setEnabled(false)

 This works here: https://ui5.sap.com/test-resources/sap/fe/core/fpmExplorer/index.html#/buildingBlocks/table/tableDef... 

axel_brke3
Participant
0 Kudos

Hi Marian,

thanks a lot for your response. This certainly is a new direction.

Unfortunately we're on 1.108 and findOn is not yet available for us.

I'll look into ways to adjust the sap.m.table by fetching it via id. I just wonder if this is much "better" than using private methods, I would expect this to be breaking easily when updating

Marian_Zeis
Active Contributor
0 Kudos

@axel_brke3 i do not think this will break easily, you can just use some form of this code from UI5.
This is the "findOn" method:

	PluginBase.getPlugin = function(oElement, vPlugin = PluginBase) {
		// Keep this function in sync with sap.m.plugins.PluginBase.getPlugin
		// until the library dependencies are cleaned up and a reuse can happen!

		if (!oElement) {
			return;
		}

		if (typeof vPlugin === "function" && vPlugin.getMetadata) {
			vPlugin = vPlugin.getMetadata().getName();
		}

		const fnCheck = function(oElem) {
			/* TBD Cleanup sap.m and sap.ui.table plugins should be aligned in future.*/
			return oElem.isA(vPlugin) && (
					oElem.isA(["sap.m.plugins.PluginBase", "sap.ui.table.plugins.PluginBase"]));
		};

		return oElement.getDependents().find(fnCheck) || oElement.findElements(false, fnCheck)[0];
	};