SmartGWT ListGrid field resize - smartgwt

My SmartGWT ListGrid have some fields, wich contain long string. I set property "countryGrid.setCanResizeFields(true)".
When I change the width of the field, I want to see something like this: |A very long dat...|
Data that does not fit, will be replaced by Dots.
But instead, my string data simply cutted, like this |A very long dat|
What property is responsible?
Here is my code:
//deptartment Tab
deptGrid.setWidth100();
deptGrid.setHeight(300);
deptGrid.setTop(50);
deptGrid.setAlternateRecordStyles(true);
deptGrid.setShowAllRecords(true);
deptGrid.setCanRemoveRecords(true);
deptGrid.setCanEdit(true);
ListGridField emplIdField_DepTab = new ListGridField("id", "ID", 40);
ListGridField nameField_DepTab = new ListGridField("name", "NAM", 200);
ListGridField deptIdField_DepTab = new ListGridField("deptId", "DEPARTMENT");
ListGridField buildingIdField_DepTab = new ListGridField("buildingId", "BUILDING");
deptGrid.setFields(new ListGridField[] {
emplIdField_DepTab, nameField_DepTab, deptIdField_DepTab, buildingIdField_DepTab
});
deptGrid.setCanResizeFields(false);
deptGrid.setShowAllRecords(true);
deptGrid.setShowRecordComponentsByCell(true);
deptGrid.setFixedRecordHeights(true);
deptGrid.setAutoFetchData(true);
deptGrid.setAutoFitMaxRecords(3);
deptGrid.setAutoFitData(Autofit.VERTICAL);
deptGrid.setShowFilterEditor(true);
deptGrid.setCanEdit(true);

You don't need to write any code for this functionality. This is the by default behavior of the ListGrid.
Please have a look at Smart GWT Showcase with live sample code for more clarity.
EDIT
The issue may be caused by using older version of Smart GWT. Try it again with latest nightly build of Smart GWT.

Related

Vaadin Combobox does not shows nameField from database

I have a service class. When I set items alldata() in my combo box then it shows all the embedded data from the database. how can I just set the name field?
example:
private ComboBox groundComboBox = new ComboBox<>("Ground");
groundComboBox.setItems(groundService.getAllGround());
it shows:
Ground(groundId=Shere-Bangla, groundName=Shere-Bangla national stadium, city=Dhaka, country=Bangladesh, longitude=90.8, latitude=45.7, capacity=10000, inaugurationDate=2005-02-05).
i just want to show the only name;
You need to set the label generator to define what will be the label of each item.
groundComboBox.setItemLabelGenerator(Ground::getName);
or
groundComboBox.setItemLabelGenerator(ground -> ground.getName());

TListView DynamicAppearance with TImageObjectAppearance will not view image when using LiveBindingsDesigner with TFDMemTable

I am welcoming Embarcaderos efforts to make TListView more dynamically, and was exited to see Sarina Duponts post here where you could just link the imageindex to the TListView properties in LiveBindings Designer, and even the image property to a datafield (integer) when using DynamicAppearance and TImageObjectAppearance.
But... I tried, and did almost succeed.
In my challenge I have an application where I use TFDMemTable with TREST* function to populate the TFDMemTable. All works well if I don't use the DynamicAppearance and use i.e. ImageListItem and links the datafield I want to use to the imageindex property in TListView using LiveBindings Designer.
With DynamicApperance though, there are no imageindex property to link to, but Sarina Dupont says in here post that you could link the integer field directly to the image property (and IDE/compiler will figure it out).
Well... I figured following out: My data fields (semicreated from TREST* and TFDMemTable) are not neccesserely what they seems to be. Since I am using REST/JSON, the fieldtypes are "anonymized" to WideString, actually the FieldDefs->'dataitem'->DataType is set to "ftWideString". I tried to change this value to ftInteger in hope that this would help, but I did just get this errormessage: "FDMemtTable1: Type mismatch in field for 'datafield', exepecting: WideString actual: Integer".
So... I was nearly there, and I really want to use DynamicAppearance and view several images and textfields for each TListViewItem...
...or is it easier to make a ListViewItem 'Template' dynamically and populate it with data instead, and what is the best way to do that ?
I usually try to avoid LiveBindings. The fastest, most stable and easiest way is to add items using code.
ListView1->BeginUpdate();
try {
for (int i = 0; i < arrayOfThings->item.Length; i++) {
TListViewItem* item = ListView1->Items->Add();
item->Text = arrayOfThings->item[i]->item_name;
item->Data["itemName"] = TValue::From<UnicodeString>( arrayOfThings->item[i]->item_name);
item->Data["itemId"] = TValue::From<UnicodeString>( IntToStr( arrayOfThings->item[i]->id ));
item->Data["itemDate"] = TValue::From<UnicodeString>(arrayOfThings->item[i]->item_date);
// adding the image - imgClock is name of the image field [TImageObjectAppearance ] added to items in ItemAppearance in the TListView object that uses DynamicAppereance
const UnicodeString imgClock = L"imgClock";
dynamic_cast<TListItemImage*>(item->Objects->FindDrawable(imgClock))->Bitmap = //bitmap source;
}
} catch (...) {
}
ListView1->EndUpdate();

Open/Libre Office macro to scroll view to selection

In Writer, I would like to search for some text and when found position the view to the top of the view/window.
Using the following code,
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.SearchString"
args1(0).Value = ":"
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
the view changes and it shows the selection but it is not in any particular place. I want it to be at the top of the window/view.
I've also found elsewhere the use of ThisComponent.currentController.getViewData() and restoreViewData(). So I experimented and determined how to change the data returned in order to get a vertical scroll but nothing happens. For example...
vd = ThisComponent.currentController.getViewData()
vdParts = Split(vd, ";")
vdParts(6) = CLng(vdParts(6)) + 1000
vd = join(vdParts, ";")
ThisComponent.currentController.restoreViewData(vd)
Any suggestions?
PS: I am running version 5.0.5.2 on Windows 7 x64
Spreadsheets have View Panes that can be manipulated, but it does not look like there is a similar interface in Writer.
Instead, use the View Cursor to go down one or two pages, then move back to the location of the search result.
Also, do not use the dispatcher for the search. Use the API instead, like in section 7.14 of Andrew Pitonyak's macro document.

Vaadin: How do I add options to a combo box?

I have a combo box that I am trying to add options to. How Do I go about this? This is what I have so far:
ComboBox contactPrefixNametf = new ComboBox("Prefix");
contactPrefixNametf.setItemCaption(contactPrefixNametf, "Mr");
fLayout.addComponent(contactPrefixNametf);
contactPrefixNametf.setImmediate(true);
I guess .setItemCaption() is not the correct method? What is the correct method?
Thank you in advance!
Use addItem() method:
final ComboBox my_combox_box = new ComboBox("My Combo Box");
for (final My_object mo: list_of_my_objects)
{
my_combox_box.addItem(mo);
my_combox_box.setItemCaption(mo, mo.name());
}
This example uses addItem inconjunction with setItemCaption() to store the actual object selected by the user with a display friendly name (if toString() is not appropriate).
myComboBox.addItem("Option 1");
(Especially if you are new to Vaadin), I suggest to try Viritin add-on and its TypedSelect variant of ComboBox. Its well typed API makes many things ridiculously simpler. For instance it has a (typed) setOptions method and its value change listeners provide the value directly instead of through untyped Property interface.
A code example of its usage:
List<Person> options = service.findMyPersons();
TypedSelect<Person> select = new TypedSelect<>(Person.class)
.withSelectType(ComboBox.class);
select.setOptions(options);
// If toString() representation is not good, modify it to something else
select.setCaptionGenerator(person -> person.getFirstName() + person.getLastName());
select.addMValueChangeListener(event -> {
Person person = event.getValue();
});
Disclaimer: I'm the maintainer of Viritin, but also have maintained Vaadin for 8 years and nowadays work as its developer advocate.

Creating HtmlSelectOneMenu dynamically - assigning SelectItem list

I have a JSF application where I need to create almost all of the UIComponents dynamically based on certain parameters to the page. The components are created and added to an HtmlPanelGrid. I've been successfully creating HtmlLabel, HtmlInputText, UISelectBoolean, and HtmlCommandButton. Now I need to create an HtmlSelectOneMenu and add it, and I'm having a hard time finding examples that show how to attach the list of items to select.
The selection list is this, where I've made cfaItems a property of my backing bean:
SelectItem[] cfaItems = {
new SelectItem(1, "1"),
new SelectItem(2, "2"),
new SelectItem(3, "3"),
new SelectItem(4, "4"),
new SelectItem(5, "5")
};
The creation of the HtmlSelectOneMenu:
HtmlSelectOneMenu cfaMenu = (HtmlSelectOneMenu)
getApplication().createComponent(HtmlSelectOneMenu.COMPONENT_TYPE);
cfaMenu.setId("cfaMenu");
grid.getChildren().add(cfaMenu);
As best as I can figure it out, I need to create a ValueExpression that would bind the cfaItems list to the cfaMenu but not finding any examples is a problem. I think that I need to do something like this
String menuBinding =
"#{" + beanName + ".cfaItems}";
ValueExpression menuVE = getApplication().getExpressionFactory().
createValueExpression(FacesContext.getCurrentInstance().
getELContext(), menuBinding, String.class);
cfaMenu.setValueExpression("value", menuVE);
But I don't think that's correct. Any suggestions?
You need to create an UISelectItems instance with the given select item array as value and then add it as child of the menu, exactly as you'd do with <f:selectItems> in the view side.
UISelectItems selectItems = new UISelectItems();
selectItems.setValue(cfaItems);
cfaMenu.getChildren().add(selectItems);

Resources