cancel
Showing results for 
Search instead for 
Did you mean: 

Factory function problem: sap.ui.table.Table

saivellanki
Active Contributor
0 Kudos

Hello All,


I am using factory function on 'rows' aggregation for sap.ui.table.table to display different control templates in one column. It doesn't give me values, model binding is working fine, I can see the scroll bar visible with paginator as well, but no values.


Please check the full code here and let me know where I might be going wrong: Plunker


Thank you!

Regards,

Sai Vellanki.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

Hi Sai

I doubt your factory implementation will work because the template is in the column object.

JS Bin - Collaborative JavaScript Debugging

saivellanki
Active Contributor
0 Kudos

Hi Dennis,

I tried something like this using 'columns' aggregation, but it doesn't seem to work:

JS Bin - Collaborative JavaScript Debugging

Following is the error I see:

Regards,

Sai Vellanki.

former_member182862
Active Contributor
0 Kudos

HI Sai

only template is allowed. You cannot use factory.

Thanks

-D

Answers (1)

Answers (1)

former_member203031
Contributor
0 Kudos

Hi Sai,

I had done some change in your code

var oTable2 = new sap.ui.table.Table("oTable", {

          visibleRowCount: 5,

          navigationMode: "Paginator",

          rowSelectionChange: function(oEvent) {

            oController.onSelectionChange(oEvent);

          }

        });

        //Define the columns and the control templates to be used

        oTable2.addColumn(new sap.ui.table.Column({

          label: new sap.m.Label({

            text: "ID"

          }),

          template:new sap.m.Text().bindProperty("text", "ProductId"),

        }));

        oTable2.addColumn(new sap.ui.table.Column({

          label: new sap.ui.commons.Label({

            text: "Product"

          }),

          template:new sap.m.Text().bindProperty("text", "Name")

        }));

        oTable2.addColumn(new sap.ui.table.Column({

          label: new sap.ui.commons.Label({

            text: "Availability"

          }),

          template:new sap.m.ComboBox({

                    width: "150px",

                    value: "{Availability}"

                  })

        }));

with that respective change i got this as output

To display the values in the combobox u have to use list items then u will get those values.

I hope this will be helpful.

Thanks,

Deepak Raj

saivellanki
Active Contributor
0 Kudos

Hi Deepak,

Yeah, that is fine. But, my issue is using factory functions how can we create different controls in 'Availability' column based on model data.

Regards,

Sai Vellanki.

former_member203031
Contributor
0 Kudos

Hi sai ,

For that u have to use formatting concept,

Available         - Success  -  green color,

Out of Stock    - Eroor       -   red color,

waiting            - Warning     - orange color.

you have to ccreate a new file Formatter.js and there u have to declare all the conditions how you are willing to display the values respective to the color.

please refer the below link about the formatter concept:

Step 23: Custom Formatters

Thanks,

Deepak.

Message was edited by: Deepak Anumula

saivellanki
Active Contributor
0 Kudos

Deepak,

I need to do something like this using sap.ui.table.Table: Plunker

Above sample is done using sap.m.Table.

Regards,

Sai Vellanki.