How to set a textbox value with the selected value of Bootstrap Typeahead? - gwt

I have the following gwt-bootstrap ui.xml :
<b:Typeahead ui:field="typeahead">
<b:TextBox ui:field="searchBox" searchQuery="true"
placeholder="Search..." />
</b:Typeahead>
How can i programmatically take the suggested response "On Click" of the the typeahead item and set it as Text into the searchbox?

Well the Adarsha Answer dont really work in my case, because i use full gwt. So my Solution is :
typeahead.setUpdaterCallback(new Typeahead.UpdaterCallback() {
#Override
public String onSelection(Suggestion selectedSuggestion) {
String text = selectedSuggestion.getDisplayString();
return null;
}
});

The below link will definitely helps you -
Get selected items value for Bootstrap's typeahead
once you get the selected value its just a matter of doing textbox.setValue(value).

Related

How to user custom Drag Appearance in smart gwt

I am trying to user Custom Drag appearance in smart gwt. how can i implement it.
Current when using DragAppearance.TRACKER its show on 10px square i want a lable with caption Drag to Lineup.
vLayout1.setDragAppearance(DragAppearance.TRACKER);
vLayout1.setCanHover(true);
vLayout1.setCursor(Cursor.HAND);
I hope, the following links will help you
https://github.com/moravianlibrary/MEditor/blob/master/editor-editation/src/main/java/cz/mzk/editor/client/view/ModifyView.java#L1100:L1104
https://github.com/moravianlibrary/MEditor/blob/master/editor-common/editor-common-client/src/main/java/cz/mzk/editor/client/view/other/EditorDragMoveHandler.java
Override BaseWidget.setDragTracker and provide required content using EventHandler.setDragTracker.
VLayout vLayout1 = new VLayout() {
#Override
protected boolean setDragTracker() {
EventHandler.setDragTracker("<pre>Drag to Lineup</pre>");
return false;
}
};
vLayout1.setCanDrop(true);
vLayout1.setCanDrag(true);
vLayout1.setDragAppearance(DragAppearance.TRACKER);
EventHandler.setDragTracker accepts any valid html code and <pre/> tags were used above to avoid word wrap.
Check following sample in SmartGWT showcase:
http://www.smartclient.com/smartgwt/showcase/#effects_dd_tracker

Magento: How to add the widget button to the WYSIWYG Products Editor

I want to allow adding the Catalog Product Link widget in the description field of a product (so I can easily link to other products in the description). I've already extended Mage_Catalog_Model_Product by creating a file like:
class mymodule_Catalog_Model_Product extends Mage_Catalog_Model_Product
{
/**
* Add getDescription function that interprets widget or static blocks
* within product descriptions
*/
public function getDescription() {
$processor = Mage::getModel('widget/template_filter');
$html = $processor->filter($this->getData('description'));
return $html;
}
}
Now it works fine if I type something like
{{widget type="catalog/product_widget_link" anchor_text="my text" template="catalog/product/widget/link/link_inline.phtml" id_path="product/1234"}}
into the description field -- it creates a link to the product Id 1234.
But I want to add the actual Catalog Product Link widget button in the WYSIWYG editor for editing a product. The button is already in the CMS editor, but I am missing what I need to modify in order to add this widget to the Admin interface for editing a product. Can someone help me out?
For anybody stumbling across this later on like myself, you can use the cms_wysiwyg_config_prepare event to set this to true.
E.G:
in config.xml
<events>
<cms_wysiwyg_config_prepare>
<observers>
<webtise_widgets>
<class>webtise_widgets/observer</class>
<method>cmsWysiwygConfigPrepare</method>
</webtise_widgets>
</observers>
</cms_wysiwyg_config_prepare>
</events>
In your observer
<?php class Webtise_Widgets_Model_Observer{
public function cmsWysiwygConfigPrepare(Varien_Event_Observer $observer){
$observer->getEvent()->getConfig()->setAddWidgets(true);
}
}
I was able to do this by overriding the core file
app/code/local/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php
and setting
$config['add_widgets'] = true;
Now the widget button shows up in all WYSIWIG editors in the admin interface.

ASPxGridView: How to disable GridViewDataColumn when a GridViewDataCheckColumn is checked or unchecked?

I have an ASPxGridView with the following columns:
<dx:GridViewDataCheckColumn FieldName="ProtocolEnabled" Caption="Protocol Enabled">
<DataItemTemplate>
<asp:Literal ID="ltProtocolEnabled" runat="server" />
</DataItemTemplate>
</dx:GridViewDataCheckColumn>
<dx:GridViewDataColumn FieldName="ProtocolCount" Width="0" Caption="Protocol Count">
The checkbox column has a template with a literal in it so I can display Yes/No instead of an empty checkbox, but that's probably TMI. What I need to do is this:
In edit mode: When ProtocolEnabled is checked, I need to enable the ProtocolCount textbox. When ProtocolEnabled is unchecked, I need to disable ProtocolCount and set its text to 0.
I am not asking for a step-by-step, but a general pointer in the right direction. I would like to use callbacks if at all possible. I also promise I will not delete this question as you are answering it =P.
Update: Thanks to answerer, I was sent in the direction I needed to go. Here's the code I used:
<dx:GridViewDataCheckColumn FieldName="ProtocolEnabled" Caption="Protocol Enabled" CellStyle-HorizontalAlign="Left">
<DataItemTemplate>
<asp:Literal ID="ltProtocolEnabled" runat="server" />
</DataItemTemplate>
<PropertiesCheckEdit>
<ClientSideEvents CheckedChanged="function(s,e) {ProtocolEnabledChecked(s);}" />
</PropertiesCheckEdit>
</dx:GridViewDataCheckColumn>
<dx:GridViewDataColumn FieldName="ProtocolCount" Width="0" Caption="Protocol Count">
function ProtocolEnabledChecked(ck) {
var x = gvApplicationServer.GetEditor("ProtocolCount");
if (ck.GetValue()) {
x.enabled = true;
}
else {
x.SetValue(0);
x.enabled = false;
}
}
It's clientside code instead of callback.
First of all Check this for Accessing Controls Contained within Templates
To show Yes/No
On HtmlRowCreated Event access control and set it's text property after finding the control in the
Literal literal = ASPxGridView1.FindRowCellTemplateControl(e.VisibleIndex,
ASPxGridView1.Columns["Name"] as GridViewDataColumn, "ASPxButtonEdit1") as Literal ;
literal.Text = (bool)grid.GetRowValues(e.VisibleIndex, "columnName") ? "Yes" : "No";
In Edit Row Template Do as you did as above..
If you want to do some client side functionality then .. create client side event OnClientClick and use checkbox client side method. chkclientinstanceName.getValue(); or other to check with it is checked or not..
these controls are client accessible so enable/ disable by using txtClientName.SetEnabled(true/false);
for more help go to the
DevExpress.Web.ASPxEditors ClientScript namespace..
Try this step by step .. hope it will be helpful..

How can I display all possible values in a SuggestBox

I would like to display all possible values in a SuggestBox.
Naturally, I have the following code (settingName is a SuggestBox)
settingName.getTextBox().addFocusHandler(new FocusHandler() {
#Override
public void onFocus(FocusEvent event) {
settingName.showSuggestionList();
}
});
Unfortunately, the suggestbox displays anything. Of course, the settingName is associated to an oracle with several values inside it.
Am I crazy ?
According to the documentation :
public void showSuggestionList()
Show the current list of suggestions.
You need to set the defaults to show by suggestOracle.setDefaultSuggestionsFromText(..)
When showing the list, the SuggestBox will ask the oracle for values to show. If the text box is empty, then requestDefaultSuggestions will be called (which by default calls requestSuggestions).

setting a default text to a GWT ListBox

I am trying to create a ListBox using GWT. I am using UiBinder to create the field.
I would like to set a default text on the list box and when a user clicks on the box, it should show me the list items. Once again, if user has not selected any option, it should show me the default text again.
Any way to do this either using Uibinder or some ListBox methods?
If I understand correctly you want a value to show but when the user clicks on the list it disappears and shows you the list items?
As far as I know there is no option to that natively.
What you can do is add the first item to hold your default value.
You can do this grammatically by using addItem in code or using:
<g:Listbox>
<g:item value="-1">Default text</g:item>
</g:Listbox>
works with gwt 2.1+
The value can still be selected.
You can choose to ignore it or add an attribute "disabled" with value "disabled" to the option element:
listbox.getElement().getFirstChildElement().setAttribute("disabled" ,"disabled" )
hope it helps a bit :)
You can also use a renderer to control what is shown if 'Null' is selected.
(Inspired by: How do I add items to GWT ListBox in Uibinder .ui.xml template ?)
private class SimpleRenderer implements Renderer<T>{
private String emptyValue = "Select a value";
#Override
public String render(T val) {
if(val == null) {
return emptyValue;
}
return val.toString();
}
#Override
public void render(T val, Appendable appendable) throws IOException {
appendable.append(render(val));
}
public void setEmptyValue(String emptyValue) {
this.emptyValue = emptyValue;
}
}