Skip to Content
author's profile photo Former Member
Former Member

Adding Rows onClick Button

Hi All,

Basically my requirement goes like this.

I have table wherein, I can see

7 Rows - one for each day of the week.

Now, on each row, there is a button, which when clicked should add a new row for that WeekDay

for example

Mon + (Now onclick this Button, a new row should get added below this for Monday itself)

+

-------------------------------------------

Tue +

+

----------------------------------------------

I am using sap.m.table. I want to know your thoughts on this,, should i use 7 different tables each for one weekday and then implement this or can this be implemented in one single table itself?

Could you guyz please share your thoughts on this?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

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

    Hi Preethi,

    Will this sample help? Plunker

    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 10, 2015 at 01:48 PM

    Please refer this example code document . it may be useful JS Bin - Collaborative JavaScript Debugging


    Kindly let me know if you need any more information

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 11, 2015 at 09:58 AM

    Hi Preethi,

    Using a single table should not be a problem, just update your model by adding a new row when user clicks on the button and apply sorting for your table to show the rows in the order you want them to be.

    Br,

    Aleksei

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 11, 2015 at 09:58 AM

    Hi Preethi,

    If you are using XML View you can try below approach.

    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.

    Reference -

    Regards,

    Abhijeet

    Add a comment
    10|10000 characters needed characters exceeded

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.