cancel
Showing results for 
Search instead for 
Did you mean: 

Table with blank rows

former_member225463
Participant
0 Kudos

Hello Experts,

I need your help in one of my requirement , where by default i have  to show 5 blank rows following a particular template in my sapui5 table and clicking on a button say add new rows , five new empty rows should get inserted into the table.

A code snipet will be very helpful .

Thanks in advance.

Regards,

Vikash

Accepted Solutions (0)

Answers (1)

Answers (1)

saivellanki
Active Contributor
0 Kudos

Hi Vikash,

Will this sample help? JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

former_member225463
Participant
0 Kudos

Hi Sai,

I want to use the same code on onbeforerendering event and my table is having no data at first time then how i can proceed here.

For me i have to call the table reference  first using this.byId("tableid") , after that do i need to use any model or i can use an array?

Regards,

Vikash

Former Member
0 Kudos

Hi Vikash,

Are you using XML view ?

Regards,

Abhijeet

former_member225463
Participant
0 Kudos

Hi Abhijeet,

Yes i am making custom fiori application using XML Views.

Regards,

Vikash

Former Member
0 Kudos

Hi Vikash,

One of the method is:

Create a Local JSON Model with blank values . Bind it to you XML view. By default you will get 1 blank row assign.

Now write a code in controller to user setProperty() of model.

See the code below:

JSON Model:

{

    "FamilyTableJson": [

        {

            "Relationship": "",

        }

    ]

}

XML View:

<table Table xmlns="sap.m" id="idFamilyTable" inset="false" items="{/FamilyTableJson}" growing="true" wrapping="true" growingThreshold="3" growingScrollToLoad="false">

<columns>

     <column hAlign="Center">

               <Text text="Relationship" />

     </column>

</columns>

<items>

<ColumnListItem>

               <cells>

                         <Input xmlns="sap.m" visible="true" value="{Relationship}"

                           enabled="true" valueState="None" name="" placeholder="Relationship..."

                            editable="true" valueStateText="" showValueStateMessage="true"

                           textAlign="Left" type="Text" maxLength="17" showValueHelp="false"

                           showSuggestion="false" valueHelpOnly="false" filterSuggests="false">

                           </Input>

               </cells>

  </ColumnListItem>

  </items>

</Table>

View Controller :

addTableRows : function()

   {

for (var i = model.oData.FamilyTableJson.length; i<10; i++)

    {

  

     model.setProperty('/FamilyTableJson/' + model.oData.FamilyTableJson.length,

         {

            "Relationship": "",

    });

    };

}

Hope this will help you.

Regards,

Abhijeet