vaadin submenu code for views - menu

Hi i m added the File menu item creating the views, my code look like
final Class viewClass : new Class[] { Dashboard.class,
Editor.class, Ticket.class, MockupView.class }) {
navigator.addView(viewClass.getSimpleName(), viewClass);
menu.addItem(viewClass.getSimpleName(), new MenuBar.Command() {
public void menuSelected(MenuItem selectedItem) {
navigator.navigateTo(viewClass);
}
});
but how to add sub menu item inside this menu, any one can help me if you provide me example it will be great full for me

menu.addItem returns a reference to the new menu item, which you can then use to add child items:
MenuBar.MenuItem item = menu.addItem("Parent", null);
item.addItem("Child", null);

Everything you need to know is on this Vaadin documentation page

Related

Remove default menu options from Add Activity dropdown on Activities tab on Case screen

I want to remove different menu options available such as Add Note, Add Phone Call, Add Work Item, etc. from Add Activity menu on Activities tab on Case screen and add it directly on the toolbar instead of it showing in dropdown.
I know I can add menu option under Actions using below command but not sure how to remove those options including the top level menu. Probably just removing from ASPX code?
Base.action.AddMenuAction()
You can refer below code snippet.
using System;
using PX.Data;
using PX.Objects.CR;
namespace PXDemoPkg
{
public class CRCaseMaintPXDemoExt : PXGraphExtension<CRCaseMaint>
{
public override void Initialize()
{
if (Base.Actions.Contains("NewActivity"))
{
PXButtonState actionsMenuState = Base.Actions["NewActivity"].GetState(null) as PXButtonState;
if (actionsMenuState != null)
{
foreach (ButtonMenu button in actionsMenuState.Menus)
{
button.Visible = false;
}
actionsMenuState.Visible = false;
}
}
}
}
}

Xamarin TableViewCell select one

I am trying to make table view cell as follows using Xamarin Studio.
public enum Category
{
Travel,
Lodging,
Books
}
I am using Monotouch.Dialog, but cannot find any element.
Any advice?
I guess what you're looking for is the RadioElement of MonoTouch.Dialog. You can see an example in section 3.1 in the MonoTouch.Dialog introduction.
From the example in the doc:
var root = new RootElement ("Meals") {
new Section ("Dinner"){
new RootElement ("Dessert", new RadioGroup ("dessert", 2)) {
new Section () {
new RadioElement ("Ice Cream", "dessert"),
new RadioElement ("Milkshake", "dessert"),
new RadioElement ("Chocolate Cake", "dessert")
}
}
}
}
With this example, you'll have a dialog with one root element called Meals. When tapping this item, you will be presented a new dialog where you can select one of the RadioElements. You create a RadioGroup for the elements that belong together, and the RootElement from which you launch the RadioGroup will show the currently selected value. There's more information about this in section 4.8. of the provided link as well.

Monotouch.Dialog RootElement that opens a UIViewController and Passing in Data

Is there a proper way to use Monotouch.Dialog (iOs) and call a UIViewController when a user clicks on a RootElement? I'm building a page of data based on an array and when clicked I'd like to open this custom view and pass in the array element.. Something like this (doesn't work). Any help is appreciated.
RootElement CreateMenuCategory(JToken menucat) {
RootElement MenuCategory = new RootElement(menucat["menucategoryname"].Value<String>());
RootElement root_element;
Section section = new Section();
foreach(JToken menuitem in menucat["menuitems"]) {
root_element = new RootElement(menuitem["menuitemname"].Value<String>(), (RootElement e) => {
return _menuitemView.LoadMenuItem(menuitem); // menuitem on view is always the same
});
section.Add (root_element);
}
MenuCategory.Add (section);
return MenuCategory;
}
That code doesn't work as the delegate always passes in the same element every time.
This is merely a side effect of how the "menuitem" variable is captured by the lambda function.
Change your foreach loop to look like this instead:
foreach (JToken iteratorMenuitem in menucat ["menuitems"]){
var menuitem = iteratorMenuitem;
//.. the rest

SharePoint show Ribbon with multiple webparts on page

I've created a sharepoint page that has an xslt webpart and a 2nd webpart that is unrelated to the question
When we add this second webpart the ribbon bar is hidden and you have to click the webpart to get the ribbon bar shown again.
Clicking the webpart isn’t something we can ask from our users so I’m trying to get the ribbon bar visible at all times with the context of our xslt listview webpart.
When searching for this problem I found out that when you search for this hidden ribbon behavior with reflector in the SharePoint source code it seems this is behavior that is designed by Microsoft as the example below shows:
public override bool Visible {
get {
if (!this.SingleWebPartPresentOnPage)
return false;
else
return base.Visible;
}
}
Someone with same problem but no solution: http://www.glynblogs.com/2011/02/list-view-selector-missing-with-multiple-web-parts-in-sharepoint-2010.html
Is it possible to force the ribbon bar to visible with server side code or can I call the javascript code that is being used when I click the webpart to show the ribbon bar?
I think it should be possible with javascript because if you click the xslt webpart the ribbon is visible but i can't reproduce the code thats being executed.
you can use JavaScript to reselect the XSLTListViewWebPart, that the ribbon appears again.
$(document).ready(function() {
var target = document.getElementById("MSOZoneCell_WebPartWPQ2");
if(target != null) {
var fakeEvent = new Array();
fakeEvent["target"] = target;
fakeEvent["srcElement"] = target;
WpClick(fakeEvent);
}
});
Below Javascript worked for me!!
<script>
setTimeout(function() {
var elem = document.getElementById("MSOZoneCell_WebPartWPQ4");
if(elem != null) {
var dummyevent = new Array();
dummyevent["target"] = elem;
dummyevent["srcElement"] = elem;
WpClick(dummyevent);
}
}, 100);
</script>
In the above script the MSOZoneCell_WebPartWPQ4 being my list view web part
A great solution is to grab the contextualInfo for the main webpart on your view page.
public class MyView : WebPart, IWebPartPageComponentProvider
{
protected override void CreateChildControls(){.............}
public WebPartContextualInfo WebPartContextualInfo
{
get
{
// get default current view webart (WebPartWPQ2)
ListViewWebPart listView = this.WebPartManager.WebParts
.OfType<ListViewWebPart>().FirstOrDefault();
// use reflection to get non-public member containing contextualinfo
var t = listView.GetType();
WebPartContextualInfo oViewInfo = (WebPartContextualInfo)t.InvokeMember("Microsoft.SharePoint.WebControls.IWebPartPageComponentProvider.WebPartContextualInfo", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.GetProperty, null, listView, new object[] { });
return oViewInfo;
}
}
protected override void OnPreRender(EventArgs e)
{
SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);
// Ensure ribbon exists.
if (ribbon != null)
{
// Load dependencies if not already on the page.
ScriptLink.RegisterScriptAfterUI(this.Page, "SP.Ribbon.js", false, true);
}
base.OnPreRender(e);
}
}
Below a version using SharePoint's Script On Demand instead of 100ms timeout or jquery. I think thats more solid, cuz it is exactly executed after the ribbon is initialized.
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
//using setTimeout to ensure it will be executed after the code of sp.ribbon.js has done its initialization
setTimeout(function () {
//try to focus the default webpart so the ribbon will show
var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
if (elem != null) {
var dummyevent = new Array();
dummyevent["target"] = elem;
dummyevent["srcElement"] = elem;
WpClick(dummyevent);
}
}, 0);
}, "sp.ribbon.js");
Similar to Thorstens solution, I use jQuery to fire the WpClick function on the mouseenter event. This approach also handles the issue where the Full Toolbar freaks out when a user first enters a page and tries to use one of the menus. You can trap the event bubble for any number of web parts on the page if desired. For example:
$("body").on("mouseenter","#MSOZoneCell_WebPartWPQ2,#MSOzoneCell_WebPartWPQ3, . . . etc.",function() {
WpClick(event);
});
Where "body" could be any parent element you want that contains the web parts to auto select when hovering.
When only one web part is of concern, or for optimal performance on large pages you could also set the event directly on the zone.
$("#MSOZoneCell_WebPartWPQ2").attr("onmouseenter","WpClick(event)");
or if jQuery is not available
var el = document.getElementById("MSOZoneCell_WebPartWPQ2");
if(el != null) {
el.setAttribute('onmouseenter','WpClick(event);');
}
Optionally, you can still force the Ribbon to appear after the page loads and before a user hovers by triggering the event manually. Just include the appropriate code after attaching the event above. e.g. using jQuery
$("#MSOZoneCell_WebPartWPQ2").mouseenter();

Winforms MDI and TreeView

I am currently working on a winforms application. In one of requirements I need to make sure that I can add a node to a treeView which is contained in a child form , when i click on a tabstrip button of the mdi parent.
if someone can please help me with this, it would be awesome and well appreciated..
Thanks and regards
GJ
In your parent form, keep a refernce to the child form around.
In the child form, add a public method or something that adds a node to the tree view. And when you click that tab strip button, just call that method on the child reference you have.
public Window
{
ChildForm childForm;
public Window()
{
childForm = new ChildForm();
childForm.Show();
}
public OnTabStripClicked()
{
childForm.AddNode();
}
}
public ChildForm
{
public void AddNode()
{
treeView.Nodes.Add();
}
}

Resources