cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to delete a Tile from tile container?

Former Member
0 Kudos

Hi all,

I have a 5 tiles in a view.In the Init method of the view i am checking a certain condition and want to delete the respective tile.

I am using the following code in init to delete


var main = sap.ui.getCore().byId("idUI_tilecontainer"); //Getting the container reference

var tile    = sap.ui.getCore().byId("idUI_tile2"); //Getting the tile reference

main.deleteTile(tile);

I am getting the following error in the console and the tile is not getting deleted.The error is referring to the standard controller TileContainer.js

Accepted Solutions (0)

Answers (5)

Answers (5)

karthikarjun
Active Contributor
0 Kudos

Hi Thivi,

Will this help? JS Bin - Collaborative JavaScript Debugging

Click Edit Button ( check this in Footer )

Thanks,

Karthik A

Former Member
0 Kudos

@Vijay:Thanks the code helps to delete the tile after its been displayed by manually clicking delete.But i want to delete before the tile is even displayed in init.

@Vladimirs thanks the code is just a dummy code .

@ all : I just checked that during the first time load of the application in init the deletetile method  is nor working and the tile container aggregation still holds 2 tiles.But if i navigate to different screen and then come back to this dashboard the init method is hit again and this deletetile works and tile container aggregation holds 1 tile but it is not reflected in the UI screen.The ui screen still shows 2 tile..

seVladimirs
Active Contributor
0 Kudos

just wondering how code you shared is working at all... can you share your legit code?

Former Member
0 Kudos

Hi all,

Following is my code

View


<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:layout="sap.ui.layout"

              controllerName="app.UI_DASHBOARD" xmlns:html="http://www.w3.org/1999/xhtml">

<Shell id="shell_dash">

<Page title="dash" showHeader="true" enableScrolling="false">

<headerContent>

<Button text="{i18n>HeaderBarHelp}" press="Handlehelp"></Button>

</headerContent>

<content>

<TileContainer  id="maincontainer">

<StandardTile

        id="tile1"

        icon="sap-icon://shipping-status"

        type="None"

        title="tile1

        infoState="None"

        press="Onpost"/>

<StandardTile

        id="tile2"

        icon="sap-icon://shipping-status"

        type="None"

        title="tile2

        infoState="None"

        press="Onpost2"/>

</TileContainer>

</content>

<footer>

<Toolbar >

<content >

<layout:HorizontalLayout >

          <FlexBox

          alignItems="End"

          justifyContent="End">

          <items>

             <Image src="images/slogo.png" height="40px">

            </Image>

          </items>

</FlexBox>

</layout:HorizontalLayout>

</content>

</Toolbar>

</footer>

</Page>

</Shell>

</core:View>

Controller


onInit: function() {

var main = sap.ui.getCore().byId("idUI_tilecontainer"); //Getting the container reference

var tile    = sap.ui.getCore().byId("idUI_tile2"); //Getting the tile reference

main.deleteTile(tile);

}

vijay_kumar49
Active Contributor
0 Kudos

Check this code. its use full

SAPUI5 Explored

seVladimirs
Active Contributor
0 Kudos

Well not sure how you are getting reference if you TileContainer ID is different in Controller. Also, double quotes in XML view is missing (after tile's title).

seVladimirs
Active Contributor
0 Kudos

Please find working example here - JS Bin - Collaborative JavaScript Debugging (press button Delete Tile2)

saivellanki
Active Contributor
0 Kudos

Hi Thivi,

IDs are different in view and controller and title of StandardTile quotes not closed.

Made those changes in your code and deleteTile is working fine: JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

saivellanki
Active Contributor
0 Kudos

Apologies Vladimirs. Didn't seen your response. However, your code should resolve the issue.

Regards,

Sai Vellanki.

Former Member
0 Kudos

Thanks i will check the same

vijay_kumar49
Active Contributor
0 Kudos

I see it is working fine - Tile Container

If possible, can you share the code?

seVladimirs
Active Contributor
0 Kudos

it should work... see screen recording below.

http://i.imgur.com/f9YYSI3.gif