Skip to Content
0
Aug 27, 2020 at 06:30 AM

Smart Table width issue

152 Views Last edit Aug 27, 2020 at 06:34 AM 3 rev

Hi,

I am facing one issue in smart table using sapui5 where I have used few property in the smart table. Please find below the screenshot of the code.

1111.png

and so on till last table columns i missed to define columns which I don't required in default screen user can select it from the table setting if he/she want to add those columns in the table so the column index sequence you will not find proper. and below is the last column screen shot

Note:

1. when we unchecked or simply click on the OK button which is in the table's setting icon where all columns are listed. then unfortunately this onBeforeRebindTable() doesn't work but if we checked the columns and click on OK button then after this method trigger and set the width for all the columns what ever we define.

2. i found that in response we got only 26 columns entry(what columns we define in ui:table and in initiallyvisibleFields property) not all the columns which are in the entity. so that is also the reason we won't able to define the width of those fields which are not actually in the ui:table.

controller:

onBeforeRebindTable: function (oEvent)

{

var oBindingParams = oEvent.getParameter("bindingParams");

var smartFilterBar = this.getView().byId("smartFilterBar");

var fieldBanfn = smartFilterBar.getControlByKey("R_Banfn");

var fieldUser = smartFilterBar.getControlByKey("R_User");

var fieldDate = smartFilterBar.getControlByKey("R_Date");

var tokenFilter1 = fieldBanfn.getTokens();

var tokenFilter2 = fieldUser.getTokens();

var tokenFilter3 = fieldDate.getTokens();

for (var i = 0; i < oEvent.getSource().getTable().getColumns().length; i++) {

if (i === 25) {

oEvent.getSource().getTable().getColumns()[i].setWidth("23rem");

} else {

oEvent.getSource().getTable().getColumns()[i].setWidth("10rem");

}

oEvent.getSource().getTable().getColumns()[i].setResizable(false);

oEvent.getSource().getTable().getColumns()[i].setHAlign("Center");

}

if (tokenFilter1.length > 0 || tokenFilter2.length > 0 || tokenFilter3.length > 0) { this.getView().byId("messageStripId").setVisible(false);

this.getView().byId("infomsgStripId").setVisible(false);

} else if (!this._isStripVisible) {

this._isStripVisible = true; oBindingParams.filters = [];

} else {

oBindingParams.filters = [];

this.getView().byId("messageStripId").setVisible(true);

this.getView().byId("infomsgStripId").setVisible(false);

} }

Please do some needful. Your help will really be appreciated !!

Thanks & Regards,

Kritika Sharma

Attachments

1111.png (72.2 kB)
1111.png (72.2 kB)