removeItem(index: Number);
index. Removed item index.
The removeItem method removes the item from the menu panel by the index.
To execute the example, the HTML page must contain links to PP.js, PP.Ext.js script files and to PP.css and PP.Ext.css styles files. Create drop-down panel with menu:
function createMainPanel() { // Create panel with menu mainPanel = new PP.Ui.MainPanel({ // Add items Items: [ { HotKey: "Item 1" }, { HotKey: "Item 2" }, { HotKey: "Item 3" } ] });
// Show panel with menu mainPanel.show(10, 10); }
Add two new items to the menu end and after the first item:
// Add new item to the menu end mainPanel.addItem({ HotKey: "New item" }); // Create new item and add after the first item item = new PP.Ui.MainPanelItem({ HotKey: "New item" }); mainPanel.insertItem(item, 1);
As a result in the drop-down panel with menu two new items will be added:
Get names of the first and last items:
// Get the name of the first item console.log("Name of the first item: " + mainPanel.getItems()[0]._HotKey); // Get the name of the last item console.log("Name of the last item: " + mainPanel.getItem(mainPanel.getItems().length-1)._HotKey);
As a result, names of the first and last items are displayed in the console:
First item name: Item 1
Last item name: New item
Remove the third item in the menu:
// Remove the third item mainPanel.hide(); mainPanel.removeItem(2); mainPanel.show();
As a result, the third item is removed from the menu:
See also: