cancel
Showing results for 
Search instead for 
Did you mean: 

How to add Buttons inside Smart Table Tool bar

Former Member
0 Kudos

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

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.

former_member131774
Contributor
0 Kudos

Hi Tejas,

I found solution is to use customToolbar tag in xml view.

Please see detail coding above.

Best regards,

Vincent

0 Kudos

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

former_member131774
Contributor
0 Kudos

Hi ,


You need to add coding like below.


Best regards,

Vincent

  1. <st:SmartTable id="objectList"
  2. useOnlyOneSolidToolbar="true" enableAutoBinding="true"
  3. showRowCount="true" tableType="ResponsiveTable" useExportToExcel="false"
  4. useTablePersonalisation="true"
  5. header="{path: 'header>TypeNamePlural', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"
  6. entitySet="{parameter>/entitySet}" beforeRebindTable="onBeforeRebindTable">
  7. <st:customToolbar>
  8. <Toolbar>
  9. <ToolbarSpacer />
  10. <template:repeat list="{meta>com.sap.vocabularies.UI.v1.LineItem}"
  11. var="lineitem">
  12. <template:if
  13. test="{= ${lineitem>RecordType} === 'com.sap.vocabularies.UI.v1.DataFieldForAction'}">
  14. <Button
  15. text="{path: 'lineitem>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"
  16. press="onCallAction">
  17. <customData>
  18. <core:CustomData key="STFunction"
  19. value="{path: 'lineitem>Action', formatter:'sap.ui.model.odata.AnnotationHelper.format'}" />
  20. </customData>
  21. </Button>
  22. </template:if>
  23. </template:repeat>
  24. </Toolbar>
  25. </st:customToolbar>
  26. <Table fixedLayout="false" growing="true" growingThreshold="50"
  27. mode="{= ${path: 'meta>com.sap.vocabularies.UI.v1.LineItem', formatter: 'TemplateObjectList.ObjectListAnnotationHelper.hasActions'}
  28. ? 'SingleSelectLeft' : 'None' }">
  29. <ColumnListItem
  30. type="{path: 'meta>com.sap.vocabularies.UI.v1.LineItem', formatter: 'TemplateObjectList.ObjectListAnnotationHelper.fillPreprocessorsData'}"
  31. press="onListNavigate" />
  32. </Table>
  33. </st:SmartTable>
0 Kudos

Can you please post a screenshot of the UI which this code yields?