How to add an entry to Datagrid in GWT - gwt

I know the way that initialize datagrid with data.
But I want to be able to add entry at runtime with add button and a form.

You have to create a List of the objects which your DataGrid should contain. Also you can append an object to the list, if you want to add a new entry.The objects should be of the same type as your DataGrid,you are defining it when you create or extend the Datagrid (between the < > ) . Then call the .setRowData(list) and the datagrid will be filled up. If you want to add a new list, clear the datagrid before and call .setRowCount(0).

Related

Drools Business Central Workbench - Test Scenario: List subproperty on object

Is there a way to populate a List property on an object being tested under the "new style" test scenario?
I see some "legacy" test cases which seem to achieve this so am wondering if the new style test scenario handles this.
I added the List model to my test case, which enabled me to expand the sub-property on the object, however there is only one field available there, "empty" (boolean). Is there a way to add an object here? If it makes any difference, the model is an external java dependency.
Update
The reason I wasn't able to add the List of objects was because I didn't explicitly import that object dependency into the test. Once you import it you can follow the steps given in the answer below.
It's definitely possible to manage a List property under the Test Scenario Editor.
Please consider the following example: A Book class with a List<String> property named topics.
Creating a new Test Scenario assets, please select the column where you need to add the List property, and in the right part of the editor select the property expanding the Book class, as shown below:
Pressing Insert Data Ojbect button will assign the selected List property to the selected column:
To fill the data in the List property, please double click on the Insert value cell, in the first scenario data row. A popup will appear. Its aim is to fill data inside a collection
To add a value, please press the Add list value link in the bottom part of the popup. Here, you'll be able to fill a single item on the list
Repeat this step for all the items you need to add to the list. When completed, simply press to Save button
The popup will close and you should see the previously selected data cell filled with a label similar to List(2), the number represents the number of the items in the list.

Not able add combobox as edittor for a combobox cell GXT 3.1.2

I want to add a combobox in my grid, which would populate its store(of grid) as user provide the word.
If i am adding a custom abstract cell in to grid, I can able to add combobox as edittor to it. But when i am trying to use combobox cell (need to display text in a input tag/ Editable), Combobox is not adding to Grid.
Mean to say when I click on that column, it's not converting to combobox.
Tried with adding keyuphandler to addHandler method. But It's not coming to that handler.

How to add div id in an Abstractcell created using uiBinder and UiRenderer

Im creating a cellList and using UiBinder for the abstractCell. I want to add div ids to the elements of the cell. How can I achieve that.
You can set the ids that you want in your UiBinder. They will be the same for all cells, but you can easily find the element that you need by calling getElement on your cell and iterating through its children nodes, or by using getInnerHtml and indexOf.

How to get a textbox by its name in gwt

Lets say I have a layout panel having multiple textboxes.
Now I want to get a particular textbox in that panel by its name. How can I do that?
Thanks in advance.
One way to do it is to keep references of the textboxes in a hashMap while you create them.
You need to be careful about memory leaks though.
Another way is to use GWtQuery. You could access then by name any element in the DOM.
To get it without without GWTQuery you can do that:
Element element = Document.get().getElementById("myTextboxID");
TextBox box = new TextBox();
box.wrap(element);
Since gwt has not a css-selector implementation, I would use gwtquery aka gquery whose selector implementation performs really well.
Apart from many other features, it is able to return the widget asociated with any element:
import static com.google.gwt.query.client.GQuery.*;
[...]
// if the textbox is already a widget
TextBox b = $("input[name=first_name]").widget();
//Or it its an element
TextBox b = TextBox.wrap($("input[name=search]").get(0));
b.setValue("Foo");

How to set up binding for an array with Gwittir and GWT?

I have an list of checkboxes on a GWT widget using Gwittir. I want to bind these checkbox values in my view to some values in my Model so that I can tell which ones are selected. How can I set up a binding to do this?
For a single value (one not in an array), I've been doing this:
Binding binding = new Binding();
binding.getChildren().add(
new Binding(viewObj.getTextBox(),"value",modelObj,"textValue"));
But I don't know how to transition this to work for an array of items. Please help.
I ended up not using Gwittir for those parts which dealt with arrays of data. Instead I manually transferred the data from my view to my controller when the user clicked a button which would record the state of all the checkboxes in an array to an array of values in the controller.