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

How to add Buttons inside Smart Table Tool bar

Hi All

I am facing issue in adding buttons inside the smart Table tool bar using XML. which is shown in the below picture and I want to add buttons in the highlighted area ( Edit, Copy and Delete should go down)

I have attached the code also below.

<OverflowToolbar class="sapUiMediumMarginTop">

<ToolbarSpacer width="1000px"/>

<Button text="Edit"/>

<Button text="Copy"/>

<Button text="Delete"/>

</OverflowToolbar>

<smartTable:SmartTable id="LineItemsSmartTable" entitySet="LineItemsSet" smartFilterId="smartFilterBar"

tableType="Table"

editable="true"

useVariantManagement="true"

useExportToExcel="true"

useTablePersonalisation="true" header="Items" showRowCount="true"

persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true">

<!-- layout data used to make the table growing but the filter bar fixed -->

<smartTable:layoutData>

<FlexItemData growFactor="1"/>

</smartTable:layoutData>

</smartTable:SmartTable>

Can anyone please help me to resolve this issue?

Capture.PNG (25.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 29, 2015 at 09:22 AM

    Hi I found a way to achieve this:

    you have to add the following code in your oninit function after binding the model to the smart table:

    var toolBar = sap.ui.getCore().byId("__toolbar3");

    toolBar.addContent(new sap.m.Button({text: "Refresh"}));

    Te Id of the toolbar is not dynamic. However, the Id(__toolbar3) might change between snapshots. So you better find the Id by doing inspect element on the toolbar before you implement this. If you have any doubts get back to me. Good luck. 😊

    Regards,

    Tejas Sastry

    Message was edited by: Tejas S. Gargeya Sastry

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 13, 2016 at 02:29 AM

    Do this first:

    var oTable = this.getView().byId("<yourSmartTableId>").getTable(); //this will give you the table reference

    var oToolbar = oTable.getHeaderToolbar(); //this 'should' give you the reference to the toolbar.

    now you can add controls.

    oToolbar.addContent(oControllerYouNeedObject);

    I haven't tried this. Just try it and let me know if it works. If it doesn't post an image of any error that you notice.
    You can also try getting the toolbar reference by ID during run time. Check out my previous answer.

    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.