Skip to Content

Table with blank rows

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 09, 2015 at 11:02 AM

    Hi Vikash,

    Will this sample help? JS Bin - Collaborative JavaScript Debugging

    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Vikash Rakshit

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.