How do you hidden/show particular context menu item in flex? - apache-flex

var contextMenu:ContextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
var contactList : ContextMenuItem = new ContextMenuItem("Add to Existing List");
contactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doStaticListCommand);
var newContactList : ContextMenuItem = new ContextMenuItem("Add a New List");
newContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doNewStaticListCommand);
var removeContactList : ContextMenuItem = new ContextMenuItem("Remove contact from List");
removeContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doRemoveListCommand);
var deletecontact:ContextMenuItem = new ContextMenuItem("Delete contact");
deletecontact.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, dodeleteconactCommand);
var TimeList : ContextMenuItem = new ContextMenuItem("Add Time Spent");
TimeList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doTimeListCommand);
contextMenu.customItems.push(contactList);
contextMenu.customItems.push(newContactList);
contextMenu.customItems.push(deletecontact);
contextMenu.customItems.push(removeContactList);
In flex i done contex menu , if i rigt click then show context menu item but i want to hidden particular context menu item in list , is it possiable hidden and show particular items in context menu ? please refer me , i tried key value based
if(Application.application.contact_key==1)
{
contextMenu.customItems.push(deletecontact);
}
else
{
contextMenu.customItems.push(removeContactList);
}
contextMenu.customItems.push(TimeList);
return contextMenu;
Within itemRenderer
All coding on contactListItemRenderer.as and call to datagrid like
<mx:DataGridColumn itemRenderer="com.view.Contact.ContactListItemRenderer"
dataField="fullName" headerText="Full Name" />

You can access the custom menu items by contextMenu.customItem and hide/show any particular item. For the build in menu items you can access contextMenu.builtInItems (see the code below):
contextMenuCustom.builtInItems.zoom = false;
contextMenuCustom.builtInItems.save = true;

Related

JavaFX TreeView hide context menu when tree is empty

I have a TreeView with a context menu, all works except when tree is empty. When tree is empty, I want to prevent show context menu to user.
//Set up context menu and menu items
final ContextMenu contextMenu = new ContextMenu();
final MenuItem miSubir = new MenuItem("Subir");
final MenuItem miBajar = new MenuItem("Bajar");
final MenuItem miBorrar = new MenuItem("Borrar");
//add events from clic on menu items
miBorrar.setOnAction((ActionEvent event) -> {
...
});
...
//Add menu items to context menu
contextMenu.getItems().add(miSubir);
contextMenu.getItems().add(miBajar);
contextMenu.getItems().add(miBorrar);
//Associate context menu to treeview
treeEjercicios.setContextMenu(contextMenu);
When I use Table component, I fix the problem with:
row.contextMenuProperty().bind(
Bindings.when(row.emptyProperty())
.then((ContextMenu) null)
.otherwise(contextMenu)
);
But I don't know how to apply to use with TreeView or any other alternative?
If the root item is shown, i.e. tree.setShowRoot(true), it can be supposed that when the root item is null the treeview is empty. So we can bind it
tree.contextMenuProperty().bind(
Bindings.when( Bindings.isNull( tree.rootProperty() ) )
.then( (ContextMenu) null)
.otherwise( contextMenu )
);
Else if the root item is not show, then the tree can be supposed to be empty if this root item has no children, i.e. when isLeaf() returns true. In this case the binding will be:
tree.contextMenuProperty().bind(
Bindings.when( tree.getRoot().leafProperty() )
.then( ( ContextMenu ) null )
.otherwise( contextMenu )
);

Hide siteMapNode when at particular view

I have siteMapNode inside SiteMap in Web.sitemap and want to hide one of the menu items, when I am at the page .../example.aspx?title=hiding
I tried to hide that menu from example.aspx.cs at Page_Load with smth like:
MenuItemCollection menuItems = Menu.Items;
MenuItem menuItem = new MenuItem();
foreach (MenuItem item in menuItems)
{
if (item.Text == "home")
menuItem = item;
}
menuItems.Remove(menuItem);
but I couldn't find needed item. Also I have tried to add logic into MenuTop_MenuItemDataBound, but it isn't executing at every url change

Xamarin Forms Labs GridView not showing up

I'm trying to use GridView from Forms Lab. Problem is that I'm not getting anything shown on screen. One thing to note - when i set Content = gridView or Content = mainLayout I'm getting null pointer reference exception, but i cannot find out which element is null. Here's code in view :
var itemTemplate = new DataTemplate(typeof (MedicineBoxItemCell));
var gridView = new GridView();
gridView.ItemsSource = medicineBoxViewModel.MedicineBoxViewModelItems;
gridView.ItemTemplate = itemTemplate;
StackLayout mainLayout = new StackLayout();
mainLayout.Children.Add(gridView);
var scrollView = new ScrollView()
{
Content = mainLayout,
BackgroundColor = Color.Yellow
};
Content = scrollView;
}
public class MedicineBoxItemCell : ViewCell
{
public MedicineBoxItemCell()
{
var name = new Entry()
{
HorizontalOptions = LayoutOptions.FillAndExpand
};
name.SetBinding(Entry.TextProperty, "MedicineBoxItem.Medicine.Name");
View = name;
}
}`
What platform are you testing? This a very alpha version that has some problems, specially with ItemTemplate.
Try one of the demo ViewCells and see if it works for you.. and go from there.
One thing that will not work is having a layout inside a layout on the template. For example, if you are using a Grid, and inside the grid u have a stackpanel that stackpanel and it's contents will not appear , it s somethign we don't know how to fix yet.

jqGrid Toolbar CustomButton OnClick: How can I get the parent grid row id?

I am using the jqGrid for ASP.NET MVC, and have a grid with a subgrid. In that subgrid, I have added a button to the toolbar like so:
ToolBarSettings = new ToolBarSettings()
{
ShowRefreshButton = true,
CustomButtons = new List<JQGridToolBarButton>()
{
new JQGridToolBarButton()
{
Text = "Custom",
Position = ToolBarButtonPosition.Last,
OnClick="CustomClick" }
}
},
etc...
}
The CustomClick is a javascript callback, and it fires without any problems, but I am having trouble getting the parent grid row id in the CustomClick callback.
How can I get the parent row id in the CustomClick function?
Thanks, Dennis
The child Grid id itself contains the parentKey. when ever a child grid is created the id of the child grid is ParentGridName_ParentKey_ChildGridName. So you can get the Parent key
Below is the code for custom button :
<CustomButtons>
<Trirand:JQGridToolBarButton ToolTip="Custom button" OnClick="GetParentKey" />
</CustomButtons>
Then inside GetParentKey function you can get the parentKeyID as follows :
function GetParentKey()
{
var GridId = this.id.toString().split('_');
var parentKey = GridId[1];
}
Inside of CustomClick function you has as this the DOM element of the table from which navigator the custom button are clicked. There are no "parent row", but you can get the id of the currently selected row (if any exist) per
var rowid = $(this).jqGrid('getGridParam', 'selrow');
see example from the following answer oder search for another examples to the navButtonAdd method.

Flex 4 Drag-n-Drop with custom DragProxy

I'm doing the drag an drop of an ItemRenderer manually (DataGrid) and want to know how to generate a custom DragProxy of a component that hasn't been added to the display list.
I tried something like this but didn't work:
private function doDrag(event:MouseEvent):void
{
var dragSource:DragSource = new DragSource();
dragSource.addData(data, 'dnd_format');
//var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(this));
var btn:Button = new Button();
btn.label = 'New Button';
var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(btn));
var dragProxy:Image = new Image();
dragProxy.source = bm;
DragManager.doDrag(this, dragSource, event, dragProxy,0,0, 0.6);
}
So, I want to be able to create the DragProxy using a component, the button is just an example.
Any ideas?
My guess is that this is not working because you are trying to get a bitmap from a component that was just created and has not been added to the stage. I would try testing this code with using an embedded image as the drag proxy first. If that works, then try getting a bitmap from a component that exists on the stage. My guess is that both cases will work.

Resources