Bind A Drop Down Dynamically On Sap.m.table - SAP Community
Bind A Drop Down Dynamically On Sap.m.table - SAP Community
Srikar
Active Participant
2017 Aug 20 8:32 PM
1 Kudo 8,674
Hello All,
A few weeks back I had a requirement where I am dealing an application and the
application contains dynamic Javascript where we have dynamic panels generated and
Inside the panels we had a sap.m.Table with one row on each table in the panels. On the
first row of sap.m.Table contains a column with an add button and using this we can add
the rows in each table for each panel. Inside the table, we had another column which is a
drop down and their after placing a drop down I have faced binding issues because each
row with drop down column should be bound. This became an outstanding issue for me.
Also, this issue is because using ID's for dropdowns and this made me learn when I was
binding dropdowns dynamically with javascript. Using the bindAggregation syntax for
drop down I was not able to achieve the dynamic binding of Dropdowns. So, in that
case, I used models and I have achieved binding as below.
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 1/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
I can point you to a sample demo application code where I have explained you with a
clear-cut idea. So we have taken an XML view and coded the view to have a table with
dropdowns and text fields.
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 2/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
Below code is for having a table with 4 columns and you can simply copy it and paste it
into your SAP UI5 application view. So using this code you are ready for building a table
with columns. After creating the columns, we need to switch to the controller part where
we will write the code for the column list item in order to have drop downs in the view. So
we will place the below code.
Also, you can see the template where we are having 3 dropdowns and a label. Below
code is for adding dropdowns with a model name after loading the JSON model.
Therefore, ProductMod , nameMod,QtyMod will be the models for the drop downs
without Id.
I have created a template for all the drop downs and text elements.
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 3/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
41 }
42 }),
43 new sap.m.Text({
44 text: "{Status}"
45 })
46 ]
47 });
In order to bind them, we need a sample JSON. So below you can find the sample JSON
file code where you can load them into your project structure and load into your
controller.
Let us have a sample data to bind the drop downs and tables
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 5/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
41 "Id1": "4"
42 }];
43
44 //Quantity Sample JSON
45 var Quan = [{
46 "qty": "10"
47 }, {
48 "qty": "20"
49 }, {
50 "qty": "30"
51 }, {
52 "qty": "40"
53 }];
Now let us first bind all the drop down data using the models
Using the bind Aggregation syntax I was able to bind the Table with dropdowns.
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 7/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
To Avoid the above-highlighted issue and bind the drop-down data dynamically to each
row...
1 new sap.m.Select("", {
2 items: {
3 path: "ProductMod>/",
4 template: oTemplatePc,
5 templateShareable: true
6 },
7 selectedKey: "{ProNo}"
8 })
So all we need to do is have selected key "KeyValue" bound to the drop down
Therefore we can have the following output according to the sample JSON data ...
So this is how I have resolved the Issue and able to get the drop down. So according to
my skillset, I have written to this blog and make others get some knowledge. Feel free to
comment and ask questions
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 8/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
Cheers ...
Tags:
1 Comment
former_member553641
Explorer
2018 Jan 31 7:19 AM
0 Kudos
Dear Srikar,
I like your post, can you please look into my issue, when I am binding drop down within
the table, my scenario seems little different than you, as I need to bind drop down after
adding the row object,
Please review my post here,
https://answers.sap.com/questions/418155/bind-a-drop-down-on-every-row-added-
dynamically-on.html
Comment
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 9/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
ABAP CDS VIEW 2 ABAP CDS Views 13 ABAP CDS Views - BW Extraction 3
ABAP CDS Views - CDC (Change Data Capture) 3 ABAP Class 3 ABAP Cloud 11
ABAP Cloud Developer Trial 1 ABAP Cloud Landing Page 1 ABAP Custom 1
ABAP for EWM 1 ABAP in Eclipse 3 ABAP Interface 1 ABAP New Syntax 2
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 10/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
ABAP String functions 1 abap technical 1 ABAP test cokpit 1 abap to xml 1
Related Content
Custom Tile Visualization & Navigation in SAP Build Workzone - Cloud foundry
launchpad: Solved
in Technology Blogs by SAP yesterday
Exactly once in order (EOIO) for Group messages using Advanced Event Mesh
in Technology Q&A Saturday
Material Description in Adobe Form not showing line breaks – All text appearing in
single line
in Technology Q&A Thursday
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 11/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
former_member200339
Participant
jeffrey_towell2
Participant
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 12/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
1268420 75 345
Difference between SAP S/4HANA :Public Vs Private edition : RISE with SAP
rajarajeswari_kaliyaperum
Active Participant
211342 48 321
MioYasutake 6
dirkfrick 5
Sandra_Rossi 5
Arunagirish1 4
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 13/14
4/28/25, 4:32 PM Bind a Drop Down Dynamically on sap.m.Table - SAP Community
Michał_Biegun 4
PasupuletiVenuGopal 3
Clement 3
Nihal_Nath_Tiwary1 3
BH91976 3
fellipe_mendes 3
View all
Trademark Support
Cookie Preferences
Follow
https://community.sap.com/t5/technology-blogs-by-members/bind-a-drop-down-dynamically-on-sap-m-table/ba-p/13311714 14/14