cancel
Showing results for 
Search instead for 
Did you mean: 

Creatins a table with dynamic number of columns.

Former Member
0 Kudos

Hi Experts,

I am creating a mobile timesheet app in which I have WON and dates {1,2,3,....31} as a column. Since the number of days in month is not constatnt I can't have always column for 31 days. Hence I want to find a way by which we can cretae table with dynamic column in which number of column will come from some variable/model data in initialization method of controller. 

Since I am creating mobile application , I am using sap.m library. One more problem is I want sap.m.table to have scroll bar keeping first column fixed and others scrollable. I know that the fixed column functionality is supported by desktop table(sap.ui.table) but I want to know is there any way by which we can acheive this functionality.

Please help me with this.

Thank you,

Dhiraj More

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Maksim,

I forgot to tell you that  I am using XML view. I was expecting the same in javascript but i want to know if something like this we can do it in XML while defining <column List ITem tag or IPUT tag>.

<items>

                    <ColumnListItem>

                        <Input type="Text" value ="{WON}" editable= "true" />

                        <Input type="Text" value ="{DESC}" editable= "true"  />   

                        <Input type="Text" value ="{1E}" editable= "true" liveChange="updateTotal"  />

                        <Input type="Text" value ="{2E}" editable= "true" liveChange="updateTotal" />

                        <Input type="Text" value ="{total}" editable= "false"      />

                    </ColumnListItem>

                </items>

Thank You for your immmediate help....

Regards,

Dhiraj More

Former Member
0 Kudos

Hi Maksim,

I have one more query I want that the column having SAT and SUN should be non editable and its value is to be hardcoded with 0.

Could you please tell me how we can do it if we are passing the data from Model. Whenever we are giving name to column "SAT/1" and "SU/2" at that time I want to make it non-editable and hardcoded. I am using below syntax to define model.

var oData = { columns : [ ],

            Data : [ {

                'WON' : "1234569",

                'DESC' : "Toronto",

                '1E' : "9",

                '2E' : "8",

                '3E' : "7",...................................}];

I am doing like this because data is going to come from model(ODATA Model). For the time being I am providing JSon data.

I know if I define data the way you did it can be more easy. But my requirement is to fetch data from model.

var ={columns:[],

          data:[]                         //This way it is easy.

};

Thank You.

Dhiraj More

former_member182372
Active Contributor
0 Kudos

            columnListItem.addCell(new sap.m.Input({

        

              editable : (new Date(2015, 2, i+1).getDay()!=0 && new Date(2015, 2, i+1).getDay()!=6),

             

              value : "{" + "data_" + (i+1) + "}"

            }));

Former Member
0 Kudos

Hi Maksim,


It is very close to what I wanted. Thanks you very much for your prompt and immediate help.

I appreciate the way you sharing your knowledge/expertise with others.


I have one more small challenge for you. Please find my query on the below discussion title:


How to get row index in which field change triggered an event.

Thank You very much for your help.


Regards,

Dhiraj More

Former Member
0 Kudos

Hi Maksim,

Two more problems in above discussed requirement.

1. To have last column TOTAL which will have sum of all the efforts for whole month.

2. To have last row TOTAL which will have total efforts logged for different projects on daily basis(daywise).

To make it more clear I am also specifying layout.

Table Header:

WON     DESC     SU/1     MO/2     TU/3 .......  MO/30     TU/31     TOTAL  

Table ROW

123455   XYZ          8          4          3                    5          6               [8+4+3+....+5+6] 

....                            4          2

.....rows                   3          1

TOTAL             [8+4+3]  [4+2+1] .... likewise

Thanks for your valuable help and time.

Regards,

Dhiraj More    

Former Member
0 Kudos

Hey

Thanks for your input. This is of great help but still I want to know if we can have some column fixed in our sap.m.table.

Regards,

Dhiraj More

former_member182372
Active Contributor
0 Kudos

dont think so, you should use demandPopin, popinDisplay and minScreenWidth for sap.m.Table