Changing the default text of SmartGWT listgrid - smartgwt

How can I change the text which the smartgwt listgrid show by default when there is no records to display. For e.g. now it displays a text "No items to show." I want to be able to change this text. Another reason for changing is I have RTL language for my application and want to be able to enter the text in that language.

From ListGrid source:
/**
* The string to display in the body of a listGrid with an empty data array, if showEmptyMessage is true.
*
* #param emptyMessage emptyMessage Default value is "No items to show."
* #see com.smartgwt.client.widgets.grid.ListGrid#setShowEmptyMessage
* #see com.smartgwt.client.widgets.grid.ListGrid#setEmptyMessageStyle
* #see Empty grid Example
*/
public void setEmptyMessage(String emptyMessage) {
setAttribute("emptyMessage", emptyMessage, true);
}

Related

amCharts 4: display legend tooltip on truncated (with ellipsis) values only

I've enabled the legend on a amCharts v4 chart with the following code but I have issues with ellipsis:
// Add legend
chart.legend = new am4charts.Legend();
chart.legend.fontSize = 11;
// Truncate long labels (more than 160px)
chart.legend.labels.template.maxWidth = 160;
chart.legend.labels.template.truncate = true;
chart.legend.labels.template.fullWords = true;
// Set custom ellipsis as default one is not displayed correctly
chart.legend.labels.template.ellipsis = "...";
// Set tooltip content to name field
chart.legend.itemContainers.template.tooltipText = "{name}";
As you can see I had to set a custom ellipsis property because Firefox v76 displayed €| instead of … on the truncated legend labels. It happens even on the sample on the amChart website but, surprisingly, not if I open the same URL in a private tab... How can I fix that?
Then I would like to display the tooltip on the legend only for truncated labels. Adding an adapter:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return "My modified " + text;
})
of course works, but how can I identify inside the adapter code if the label that I'm processing is truncated and clear the text variable? It doesn't make sense to display tooltips for non-truncated legend items.
Not sure the most ideal way but...
You get the text inside the adaptor callback.
You can add a text.length check like:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return text.length > someValyeBasedOnMaxwidth> ? "My modified " + text: "";
})
I found the answer about the tooltip adapter; this works:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
if (!target.dataItem.label.isOversized) {
// Legend label is NOT truncated, disable the tooltip
return "";
}
// Legend label is truncated, display the tooltip
return text;
})
Still I don't know why the ellipsis are not displayed correctly without setting the property...

How to get gmail-create account-password field ToolTip information using web driver selenium

I am trying to get text box Tool tip (Gmail-Create Account-Password field) information but I am failing to handle this situation.
I am using Selenium WebDriver (java). Please find below code what I have used:
WebDriver wd = new FirefoxDriver();
wd.navigate().to("https://accounts.google.com/SignUp?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Ftab%3Dwm&hl=en");
WebElement NewButton = wd.findElement(By.xpath(".//*[#id='Passwd']"));
NewButton.click();
String Tooltip = NewButton.getText();
/*String Tooltip = NewButton.getAttribute("title"); // used this getattribute method also */
System.out.println(Tooltip);
I have used other methods also similar like this method but not working Properly & not showing any errors in console also.
Please find below methods also:
//2nd method
/*Actions ActionChains = new Actions(wd);
WebElement NewButton = wd.findElement(By.xpath(".//*[#id='Passwd']"));
ActionChains.clickAndHold(NewButton).build().perform();
System.out.println("hold");
String Tooltip = NewButton.getText();
String Tooltip = NewButton.getAttribute("title");
System.out.println("done");
System.out.println(Tooltip);*/
//3rd method
/*String tooltip=wd.findElement(By.xpath(".//*[#id='Passwd']")).getAttribute("title");
System.out.println(tooltip);
System.out.println("Done");*/
//4th method
/*WebElement ToolTip = wd.findElement(By.xpath(".//*[#id='Passwd']"));
System.out.println(ToolTip.getText());
System.out.println("Done");*/
If you want to get that tooltip which will be visible next to the Password field, you have to get that WebElement instead of the Password field. That field hasn't got title attribute, or text value. You can find the tooltip in the DOM if you search for:
<div class="jfk-bubble">...</div>
Code:
this.driver.get("copy your link here");
WebElement passwordField = this.driver.findElement(By.id("Passwd");
passwordField.click();
// Example: get the title of the tooltip
WebElement tooltipTitle = this.driver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/p/strong"));
System.out.println("The title is: " + tooltipTitle.getText());
Return:
The title is: Password strength:
This tooltip is not in the DOM at the beginning so you must set the WebElement only after click and use maybe WebDriverWait to avoid problems because of slow net connection, etc...

ListGrid doesn't want to set the width of the delete-button column

On a ListGrid, when you enable to remove a record there is a cross image stand on each record line.
Is it possible de resize this column ?
When I ask for the list of fields of listGrid it give me
for (ListGridField field : listGrid.getFields()) {
System.out.println("'" + field.getName() + "'");
}
A list of column name then a column whose name is "$54h"... I think it is the name for the delete button column.
But it seems that this code :
for (ListGridField field : listGrid.getFields()) {
field.setWidth("100%");
}
listGrid.getField("$54h").setWidth(60);
does not produce what I want : means my delete-button column is not 60px width.
Does anyone understand why ?
To solve this problem use
ListGridField removeFieldProperties = new ListGridField("View-delete", "Delete this record", 40);
listGrid.setRemoveFieldProperties(removeFieldProperties);

Vaadin Listbox Option Tooltip

Is it possible to add the title(tooltip) attribute to a listbox ot twincolselect in Vaadin?
I've tried to use setItemCaptionPropertyId() along with setItemCaptionMode() but in vain.
At the end when Vaadin renders the page, the resultant html has only the value attribute to the select component and no title attribute is present.
Update - my question should have been re-phrased to say - I need tooltip on each individual item (individual row) within a listbox or twinselect.
Here is an example for Nativeselect component
// Create the selection component
final NativeSelect mynativeselect= new NativeSelect("myLabel");
// Add some items
for (int i = 0; i < 25; ++i) {
mynativeselect.addItem(i);
}
//set tooltip
mynativeselect.setDescription("My tooltip");

how to set width of DropDown window in object choice field? customized

i am using an ObjectChoiceField in blackberry now. I have items in String array like "a", "abc", "abcdefg" etc. The application automatically sets the width based on the width of the choice items. I want the dropdown window in ChoiceField having width static which can hold the largest entry in the string array.
My question is, Can i set the dropdown window size? if yes, How could i set the width of the DropDown window (which displays all choice items of your choice field)?
Your question is not clear. In the current implementation, the drop down size is the size of the largest elements.
My guess is you want the size of the "highlighted" element after selection to be of the size of largest element?
And here it is smaller
Clarify what exactly you intend to do?
i had created a custom choice field..
import net.rim.device.api.ui.component.ObjectChoiceField;
/*
* The MyChoiceField is actually an extended class of ObjectChoiceField.
* In this, the design of an ObjectChoiceField is overloaded with providing some additional
* tasks is done. It includes a constructor and a Layout methods.
* In that Layout method the design for the ObjectChoiceField is overrided...
*/
public class MyChoiceField extends ObjectChoiceField
{
public MyChoiceField(String label ,Object[] choices)
{
super(label, choices);
}
protected void layout(int width, int height)
{
setMinimalWidth(width/2-62);
super.layout(width, height);
}
}
Now i got it...
thanks....

Resources