cancel
Showing results for 
Search instead for 
Did you mean: 

smart table with named model

siddarth_kabde
Explorer
0 Kudos

Dear fellow ui5 developers / experts,

i have to display two smart tables with two different data sources. (default odata model and named odata model eg oTempModel)

smart table with default model works absolutely fine.

smart table with named model always doesnt work. tried with numerous possibilities but could not able to succeed.

we are on sap ui5 1.71.53 version.

can any one give some valid pointers or solution if they made it work ?

Thanks in Advance

Siddarth

Accepted Solutions (0)

Answers (5)

Answers (5)

Margot
Product and Topic Expert
Product and Topic Expert

The smart control library (sap.ui.comp) only supports "a default model (named undefined)" (see the documentation here), that's why your smart table with named model does not work.

Jagtar
Participant
0 Kudos

Let me know if still have any doubt or issue i am already doing same in one view using multiple service for each different icon tab

in your Controller add in your onInit method

//either create here or take model defined in menifest

var oDataModel = new ODataModel(sServiceUrl, true);

this.getView().setModel(oDataModel, "odataModel");

in View

<smartTable:SmartTable id="idSmartTableEditUser" entitySet="results" tableBindingPath="odataModel>/EntitySet" initiallyVisibleFields="Username" showTablePersonalisation="false" >

Jagtar
Participant
0 Kudos

reason for entitySet="results" from backend getting data like below

{

results:[

{},

{}

]

}

Dipender01
Newcomer
0 Kudos

Hi Jagtar,

I have named model in manifest file but when I tried by your method, still it is not working for me. The smart table is showing no data.

Jagtar
Participant
0 Kudos

let us in manifest you declared with name otherModel then in view you bind
otherModel >/EntityName

That also work for me

siddarth_kabde
Explorer
0 Kudos

Hello jagtar

otherModel >/EntityName... could you please elaborate here... ? Thanks in advance

Jagtar
Participant
0 Kudos

@siddarth.kabde is your other smart table on view or in any fragment which you want to bind non default model

siddarth_kabde
Explorer
0 Kudos

Hello jagtar,

Thanks for extending help.

Requirement is simple - icon tab bar with two tabs.

first tab - smart table with default odata which works

Second tab - smart table with different data source I.e named model- doesn't work

junwu
Active Contributor
0 Kudos

yoursecondmsarttable.setModel(oTempModel)

siddarth_kabde
Explorer
0 Kudos

Hello Jun Wu,

Thanks for your effort to help me. i tried that.

please find screenshots. please correct me if something is wrong here.

odata model - loaded in manifest.json file.

"oModelSummary": {

"type": "sap.ui.model.odata.v2.ODataModel",

"settings": {

"defaultOperationMode": "Server",

"defaultBindingMode": "TwoWay",

"defaultCountMode": "Request"

},

"dataSource": "Z*****_SRV",

"preload": true

}


Smart Table :

<smartTable:SmartTable id="idProfitSmartTable2" entitySet="Z***Results" smartFilterId="smartFilterBar2" useExportToExcel="true" beforeExport="onBeforeExport" useVariantManagement="true" useTablePersonalisation="true" header="GL Accounts" showRowCount="false" persistencyKey="SmartTableRefApp_Explored" enableAutoBinding="false" beforeRebindTable="onBeforeRebindTable1" class="sapUiTinyMargin customSmartTable" fitContainer="true" RequestAtleastFields="ID" initiallyVisibleFields="ID" tableType="Table" initialise="onInitialise">


code to bind model to smart table control

var oNamedModel = this.getOwnerComponent().getModel("oSummaryModel");

this.byId("idProfitSmartTable2").setModel(oNamedModel);


Setting binding path in onRebindBeforeTable

oEvent.getSource().setModel(this.getOwnerComponent().getModel("oSummaryModel"))

var sFilter =

"/Z***(some parameters)/Results"

oEvent.getSource().setTableBindingPath(sFilter);

Network call is not triggering.

it always says "Right now, there are no visible columns in the table. Please select the columns you need in the table settings."


when i try to select columns, no columns are displayed.

am i doing anything wrong ? or is there any limitation like smart table can be binded only to default odata model ?.

please advice. Thanks.

Siddarth

junwu
Active Contributor
0 Kudos

how about try with a normal odata service? your current one needs input parameter.