Remove date from DatePickerCell in gwt - gwt

I have implemented a CellTable in gwt, which has a column of type DatePickerCell, which opens a datepicker on click of the cell. I would like to implement something like DateBox, which has a textbox, on click of which a date picker will be opened and date can be removed from textbox, which does not happen in the case of DatePickerCell. I have tried to extend the DatePickerCell to use DateBox instead of DatePicker.
interface Template extends SafeHtmlTemplates {
#Template("<input type=\"text\" value=\"{0}\" tabindex=\"-1\" style=\"width: 85px;\"></input>")
SafeHtml div(String value);
}
Please help in this.
Thanks in advance.

One simple way is to create your own DateBoxCell by coping the class DatePickerCell and change the DatePicker to DateBox and use your own class in columns.

Related

GXT 2.3 : Combobox : tooltip on hover

I'm using GWT 2.3.0 and Sencha EXT 2.3.1. I can not upgrade due to software requirements.
I've got a combobox, in a form, with some values.
A few of these values cannont be entirely displayer because the width of the combobox is too short. But I'm not allowed to enlarge this field.
Is there a solution to add a tooltip, or show the entire value when you are hovering the value in the list ?
Or make the displayed list larger than the display field ?
Thx,
Q.
Actually it's pretty simple. Sencha Gxt 2.3 Examples has already provide a quite good example on how to add tooltip to combobox. But I will post it again for you in here, so here it goes:
public void onModuleLoad() {
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(10);
ListStore<State> states = new ListStore<State>();
states.add(getStates());
ComboBox<State> combo = new ComboBox<State>();
combo.setEmptyText("Select a state...");
combo.setDisplayField("name");
combo.setTemplate(getTemplate());
combo.setWidth(150);
combo.setStore(states);
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
vp.add(combo);
RootPanel.get().add(vp);
}
private native String getTemplate() /*-{
return [
'<tpl for=".">',
'<div class="x-combo-list-item" qtip="{slogan}" qtitle="State Slogan">{name}</div>',
'</tpl>' ].join("");
}-*/;
The key is to use a template to render the combobox value with qtip added to each one of the value div. You can read more about it in here
If you want to see the result, it will looks like in sencha gxt 2 examples in here, just take a look at the second combobox, it will show you tooltip every time you hover the combobox item.
That's it, hope it will help you. Thanks & Regards.

Why #UiFactory ListBox makeListBox1() method influences to all UiBinder ListBoxes (ListBox1, ListBox2, ListBox3 etc)?

Ok, I have a need to use many ListBoxes in UiBinder.
Ok, in View.ui.xml file:
<g:ListBox ui:field='listBox1' visibleItemCount='3' >
<g:item value='1'> Car </g:item>
<g:item value='2'> Car2 </g:item>
<g:item value='3'> Car3 </g:item>
//more item
</g:ListBox>
<g:ListBox ui:field='listBox2' visibleItemCount='3' >
<g:item value='1'> Bike </g:item>
<g:item value='2'> Bike2 </g:item>
<g:item value='3'> Bike3 </g:item>
//more item
</g:ListBox>
// more ui binder ListBox here
Now I want to setMultipleSelect for some ListBoxes only, so I can do something like this <g:ListBox ui:field='listBox2' visibleItemCount='3' multipleSelect="true" >, it works fine but setMultipleSelect(boolean multiple) was deprecated, Google said:
#Deprecated public void setMultipleSelect(boolean multiple)
Deprecated. use ListBox(boolean) instead Sets whether this list allows
multiple selections. NOTE: The preferred way of enabling multiple
selections in a list box is by using the ListBox(boolean) constructor.
Using this method can spuriously fail on Internet Explorer 6.0.
So it means we don't use setMultipleSelect but use constructor ListBox(boolean) to set the MultipleSelection, so here is what I did in View.java
#UiField ListBox listBox1;
#UiField ListBox listBox2;
#UiFactory ListBox makeListBox1(){
listBox1=new ListBox(true);
return listBox1;
}
However, the above code apply ListBox(true) for all the ListBoxes (listBox1, listBox2, etc). I don't want all ListBoxes have MultipleSelection cos some other ListBoxes need to have single selection only.
So why #UiFactory ListBox makeListBox1() method influences to all ListBoxes & how to fix it?
Not sure provided=true can help?
Try provided=true:
#UiField(provided = true) ListBox listBox1;
public MyClass() {
listBox1=new ListBox(true);
initWidget(uiBinder.createAndBindUi(this));
}
It must solve your problem
The name of the method isn't taken into account, only the return type, and it's therefore used for all widgets in the current template with that type. If you want specific instances for some fields, then as Maksym said, just use provided=true, or you can pass arguments to your #UiFactory method so it can adapt its behavior (but that means you have to put the argument on all listboxes in your ui.xml then).
Note however that setMultipleSelect has been de-deprecated in GWT 2.6, now that IE6 support is being sunset.

DateBox/datepicker in smartGwt

I want to add a datebox similar to the one in give link
http://www.jeasyui.com/demo/main/index.php?plugin=DateBox&theme=default&dir=ltr&pitem=
in my web aplication project(smartgwt).
In short I want the datebox(jquery) equivalent in smartGwt.
when i googled i found out there is something called dateChooser in smartGwt but it works like a calendar i want something like the one in above link textfield with a button which on clicking displays the calendar and the selected date appears on the textbox.
please give any suggestions i am using smartGwt LGPL.
You can use a DateItem with useTextField=true to get the required behavior.
DateItem dateItem2 = new DateItem();
dateItem2.setTitle("Date");
dateItem2.setUseTextField(true);
dateItem2.setHint("<nobr>Direct date input</nobr>");
Check 'Date Controls' section in http://www.smartclient.com/smartgwt/showcase/#form_controls_various.
DateItem is a FormItem, meaning you need to put it in a form, and will work just like other form controls.
DateChooser on the other hand is a standalone widget that you can embed among other widgets on its own.
I haven't seen such a component in smartgwt showcase but there is something called PickerIcon which can be coupled to a TextItem to achieve what you want.
PickerIcon datePicker = new PickerIcon(PickerIcon.DATE, new FormItemClickHandler() {
public void onFormItemClick(FormItemIconClickEvent event) {
SC.say("Date Picker clicked"); // or show a dateChooser component
}
});
TextItem datePickerControl = new TextItem("datePicker", "Date Picker");
datePickerControl.setIcons(datePicker);
http://www.smartclient.com/smartgwt/showcase/#form_category_picker_icons
Hope this can help !

How can I extends GWT

I'm trying extend GWT's MenuItem, in GWT you can only place text there, what i want is place any widget like a button near the text. So I start making a sub class from MenuItem and i get many problem. Many properties are private, I cannot override them, or I must override all function which use these properties as well. And there are many stuff are only in package visiable, so my implementation must follow the original GWT Widget, use the gwt's package structure.
So I think it's not quite easy to extend the GWT Widget, I know there is a Composite class which can pack different Widget together, but that cannot solve all problem. And I don't want to use other 3rd GWT libray like smartGWT or GWTExt, they change alot and are very diffrenet from GWT.
So my question is, is there any good way to extend GWT's widgets?
Something like this?
MenuBar menu = new MenuBar();
Command cmd = new Command() {
#Override
public void execute() {
Window.alert("you clicked me");
}
};
MenuItem item = new MenuItem("click me", cmd);
item.setHTML("<input type=\"button\" value=\"click\" />What the hell");
menu.addItem(item);

How to insert HTML in TabPanel tab text?

When adding a tab in a TabPanel in GWT the parameter is:
public void add(Widget w, String tabText){...};
How to tell the TabPanel to treat 'tabtext' as HTML? Because the string I am inserting is actually a HTML. Inserting HTML in MenuItem can be easily be done with MenuItem:
public MenuItem(String text, boolean asHTML, Command cmd){...}
However, this is not the case with TabPanel, anyone have ideas to insert HTML with TabPanel 'tabText'?
Thanks
There is this method according to the JavaDoc for TabPanel: http://google-web-toolkit.googlecode.com/svn/javadoc/2.3/com/google/gwt/user/client/ui/TabPanel.html
I haven't actually tried if it works or not, but it should!
Good luck!