Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

sap.m.table dynamic column layout

$
0
0

Hi All,

 

        I want to change column names and contents dynamically based on user actions. i am using below code


   var oRulesTable = new sap.m.Table(this.createId("RulesTable"),

            {

         //   growing: true,

            visibleRowCount: 10,

        //    fixedLayout:true,

            insert: true,

            showUnread: true,

            width: "100%",

            mode: "None"

        });

 

  oRulesTable.bindAggregation("columns", "/RULESTAB/COLUMNS", function (sId, oContext) {

            var contextObject = oContext.getObject();

            var columnName = contextObject['FIELDNAME'];

            oController.columns.push(columnName);

            var lv_label;

 

 

            if (contextObject['SELTEXT'] != '')

                lv_label = contextObject['SELTEXT'];

            else if(contextObject['SCRTEXT_M'] != '')

                lv_label = contextObject['SCRTEXT_M'];

            else if(contextObject['SCRTEXT_L'] != '')

                lv_label = contextObject['SCRTEXT_L'];

 

 

            var width = "100px";

            var oLabel = new sap.m.Label({ text: lv_label });

            var oTemplate = new sap.m.Text({}).bindProperty("text", columnName);

 

 

            return new sap.m.Column({

                visible: true,

                header: oLabel,

                demandPopin: true,

                template: oTemplate,

                width: width

            })

 

 

            });

              

 

 

         oRulesTable.bindItems("/RULESTAB/DATA", function (sId, context) {

            var contextObject = context.getObject();

            var cells = [];

            debugger;

            _.each(oController.columns, function (obj) {

                cells.push(new sap.m.Text({ text: contextObject[obj] }));

            });

 

 

            return new sap.m.ColumnListItem({

                type: "Navigation",

                vAlign: "Middle",

                cells: cells,

                press: [oController.onRulesRowProcess, oController]

 

 

            })

            });



      With this code i am able to change column names but data binding was not working properly. Any one suggest me solution for this. Regards, Praveen


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>