I want to display calculator panel by double clicking the GWT NumberCell as like DatePicker cell,
how to achieve this,
External plugins can be used to achieve complex functionality.
Please refer to the following link : jQuery Calculator
Use JSNI Functions to interact with plain java script / jQuery. Follow the link to have better insight about JSNI : Writing JSNI methods in GWT
Related
I want to replicate this jQuery call in gQuery to open all closed Accordion panels at once:
$('.panel-collapse:not(".in")').collapse('show');
I have tested this on my app and it works, however I am unable to successfully implement the same logic using gQuery to call the JavaScript collapse method:
#Override
public void onClick(ClickEvent event) {
GQuery.$(".panel-collapse").not(".in").trigger("collapse", "show");
}
What is the correct way to call JavaScript methods from gQuery?
Further Info - I have successfully tested this gQuery code in my onClick method to add a test class to the affected divs - so I am certain the selector part of the above query works:
GQuery.$(".panel-collapse").not(".in, .MENU").addClass("test");
Why you can't use collapse with GQuery
IIRC collapse() is not a jQuery API method. Maybe you're using Bootstrap JS, or some jQuery plugin that provides this functionality, but it's not one of the jQuery API methods and thus it's not provided by GQuery.
Why trigger wouldn't work either
GQuery, or GwtQuery, is not a wrapper for jQuery, but a full Java implementation of the jQuery API.
What this means is that, when you do something like this:
GQuery.$(".panel-collapse").not(".in").slideToggle();
You're not invoking jQuery's $(), not(), or slideToggle(); you are using a Java library to achieve the same result.
That's the reason why trying something like trigger("slideToggle") won't work: because a) slideToggle() is not an event, but a function; and b) GQuery doesn't make use of jQuery's JS functions.
Solution with GQuery
You can achieve the same "accordion" effect using the slideUp(), slideDown() and slideToggle() functions methods. To open all the collapsed elements, just calling slideDown() on them should work:
GQuery.$(".panel-collapse").not(".in").slideDown();
For full accordion effect, combine those with the toggleClass() and removeClass() methods to mark which elements are open / closed so you know which ones to toggle when clicked.
Solution with native collapse()
Now, if you don't mind the advice... GQuery is great, but the animations are far from being as smooth as in native jQuery. I guess the same happens with Bootstrap.
If you can (and I can't see a reason why you couldn't), just use JSNI to make a native call to collapse() like this:
private native void collapseAll() /*-{
$wnd.$('.panel-collapse:not(".in")').collapse('show');
}-*/;
This requires that you load jQuery (or Bootstrap) in your page, but since you said that invoking collapse() in plain JS worked, I guess that's your case.
I'm beginner to GWT and MGWT. In my project I've a requirement that I have to enable
and disable the MGWT Botton. direct method is not given in current version of MGWT.
I've seen it in GWT button.
com.google.gwt.user.client.ui.Button b = new com.google.gwt.user.client.ui.Button();
b.setEnable(boolean);
But it is not given in MGWT.
Please help me,How can we achieve above functionality using CSS/something else
I am not a MGWT guy. And there must be some better solution. You can try low level element manipulation:
Button mgwtButton;
mgwtButton.getElement().setAttribute("disabled", "disabled");
If you take this solution it will be better to prepare later your CustomButton that extends MGWT Button with additional setEnabled(boolean enabled) method to have better API.
I want to implement slider with two knobs in GWT? Can anyone help me?
If you don't mind going with third-party library there is JQuery wrapper: spiffyui (demo) and it has Slider.java. Here is what it does:
/**
* This widget wraps the JQuery UI Slider
* and allows for single slider or double slider with range.
*
* All options can be get or set using generic
* get/setIntOption, get/setStringOption, get/setBooleanOption
* methods, but some convenience methods are provided for most popular such as
* setValues and setMinimum and setMaximum. See SliderOptions for full list of options.
* #see SliderOption
*/
Or if you want it implement on your own here is step by step tutorial: Creating a GWT Wrapper for the JQuery UI Slider
You may need to code a bit of that yourself, but you can start with the one from the gwt incubator . Get the source and add another "knob" element to it. That way you can insure the two "knobs" interact the way you want them.
I ended up implementing the following to get a JQueryUI slider into GWT
http://www.zackgrossbart.com/hackito/gwt-slider/
I just downloaded a custom minimized version of JQueryUI to include the slider (only 68k) which was pretty sweet. Ended up UI Binding it and it worked like a charm;
I customized the above to implement an percentage slider (one handle, limited to 0-100) which could be re-used pretty easily. You can find my version here How to implement a JQueryUI slider in GWT
I want to use a link or a button like (a href="..."/>) in GWT with uiBinder.
I found the widget "hyperlink" but I don´t know how I use that.
You should use the Anchor widget.
You can use a sample ClickHandler on it to detect the click event or use the default href with the constructor :
Anchor(boolean useDefaultHref)
You can also use the setter setHref(java.lang.String href)
In UiBinder :
<g:Anchor ui:field="mylink" href="/myurl">The link test</g:Anchor>
EDIT :
To open the link in a new tab, you should use the setTarget(String target) method like the following example :
setTarget("_blank");
Unless you need to programatically do things with the anchor, you can just add the html into the uibinder code directly. In fact, UIBinder is not just a WYSIWYG, but it is a place for you to enter as much native HTML as you can. That makes for leaner and faster web apps.
we've used a combination of GWT and smart gwt to add some features to an app we've built.
The problem I have is that we decided to make use of the accordion functionality (SectionStack's) that SmartGWT offers and we are nesting our stock gwt widget inside a canvas and then nesting that inside the section stack. E.G
SectionStack(SmartGWT)->Section(SmartGWT)->Canvas (SmartGWT)->VerticalPanel(GWT) -> Other GWT Widgets (HTML, labels etc)
Before we mixed GWT and SmartGWT it was possible to select text in the standard GWT widgets and then copy and paste etc. Nesting the GWT widgets in the SmartGWT canvas means this is now not possible. Can anyone offer an explanation why this is the case and/or a solution on how to fix it.
I've tried canvas.setCanSelectText(true); but this doesn't seem to do anything either.
We're using GWT 2.1 with SmartGWT 2.2. The demo app using SmartGWT2.2 seems to exhibit the same problem over at http://www.smartclient.com/smartgwt/showcase/#featured_gwt_integration . I've also tried GWT 2.0.x with SmartGWT 2.2
Any help appreciated.
For those interested I've managed to find a bug registered for this at : code.google.com/p/smartgwt/issues/…
Actually it is not an issue. You have to call the setCanSelectText method on the WidgetCanvas wich is wrapping your GWT widget. The WidgetCanvas is created in the addItem(Widget) method. One way to go is to override the addItem method like this:
#Override
public void addItem(Widget widget) {
if (widget instanceof Canvas) {
addItem((Canvas) widget);
} else {
WidgetCanvas wg = new WidgetCanvas(widget);
wg.setCanSelectText(true);
addItem(wg);
}
}