I am developing application using vaadin framework.
I need to add layout(Form) inside a table component. I have created a table with two column,
This is my code
Table table = new Table();
table.addContainerProperty("Id", Integer.class, null);
table.addContainerProperty("Name", String.class, null);
for( int i = 0; i < 50; i++) {
table.addItem(new Object[] {i, "xyz"}, Integer.valueOf(i));
}
table.setSelectable(true);
table.setSizeFull();
When I am clicking on record, I need Form layout which containing TextField's in between the clicked row and next row.
Previously I was using child window and added to the application window, acts as the overlay to the whole page.
But my requirement is the exactly between the two rows in table.
Can any one help, how to do this in Vaadin.
Probably you want edit the all selected records on table. For this you can use Property.ValueChangeListener. When event occurs you can get all selected records and put them to wherever you want. Of course you must create dynamic form elements for every selected record.
Related
I am adding new record in grid like below
var newRow = Ext.create(gridModel);
rowEditPlugin.cancelEdit();
gridStore.insert(0, newRow);
reportGrid.getView().refresh();
reportGrid.getView().getSelectionModel().select(0);
//rowEditPlugin.startEdit(0);
rowEditPlugin.startEditByPosition({
row: newRow,
column: 0
});
I want this newly added record to be shown as dirty, user should know that this row is added newly i.e. red marks on top of each column.
You can supply a method to the viewConfig of your grid, called getRowClass. This method will allow you to customise the CSS class for the row.
You can tell if your record is newly inserted or not using the Model#phantom property
And, finally, you can modify the CSS for your application using SASS/Fashion to change the appearance of your newly added rows.
I'm using PagedFilterTable in Vaadin to manage pagination. When loading default page, I have set something like this - and I include sorting by some field:
if(this.sortField != null){
table.setSortContainerPropertyId(this.sortField);
table.setColumnWidth(this.sortField, 80);
table.setSortAscending(true);
table.sort();
}
So that happens when the page is loaded and that is fine. After I submit new entry (entries are being added through new, popup window), table gets new row, but the table loses it's sort order in view after popup closes, so sorting is no longer keeped. Problem is I do not know how to get to that table element from that popup window and set sorting again. Why table is being updated and I see it, and sort doesen't? Problem is bigger because I have both windows in separate files and seems to me I can't grab table element easily without modifiying the logic because I am in another window.
How to reload table so that the sort stays same?
I managed to do this after submit:
getUI().getPage().reload();
With that it works, but I am not satisfied. After that line of code, everything reloads again (meaning all queries execute again). Result is good but I don't want after submit whole reloading of page happens (also because none of my other buttons do reload). So I would like only to reload table in parent window.
How can I grab table object from outside window and for example set it's change to immediate and correct change?
Something like this I suppose needs to be written:
getParent().getUI().setImmediate(true);
?
Or better question, how to manage to table sort remains the same after inserting new entry through new window?
I managed to solve it. On the parent window in the windowCloseListener I just added:
myTable.refreshTable(data);
myTable.sortTable(); // my custom method that was Invoked on the page load too
I want a behavior like if you click on the first listitem open do a thing, if I click on the second listitem do other thing. Same thing for the third and second.
Similar to switchboard but not in iconview (I have the animason and gtk.stack set up):
https://www.youtube.com/watch?v=Lj2wKNYVFR8
This is the code:
var listbox = new Gtk.ListBox();
listbox.set_activate_on_single_click(true);
var l = new Watcher.List.ListItem("title", "subtitle");
listbox.insert(l, 0);
var l2 = new Watcher.List.ListItem("title2", "subtitle2");
listbox.insert(l2, 1);
"l" and l2 is a Gtk.ListBoxRow object so basically I add 2 listboxrow item into a listbox.
When I click on an Item do stuff:
listbox.row_selected.connect( ()=>{
stack.set_visible_child_name("new");
back.set_child_visible(true);
});
It will always show the stack child named "new" whether I click the first or second item in the list. I can acces the ListBoxRow index but that is just only for a specific Row.
I need to add custom formated items into a list and I was told that ListBox can do it. (Others can't?)
My ListBoxRow is just a grid with two labels in it but I want to add buttons and some more later.
Look at the reference for Listbox.row_selected(): You'll see that it has a ListBoxRow argument. You should update your row_selected closure to have that argument as well -- then you can use the row inside the closure to figure out which child you want to set visible.
If you really need to know the index of the row inside the listbox, you call row.get_index().
I have created a table and a button. On click of that button i need to add the row.
For that i have used buttonClick method in which i am adding a row in the Table.
The problem is that the row in added to the table (I can see in the logs),
but the screen becomes blank with just the button displayed.
If I exit and navigate again to the screen, then i can see the new row added.
How can i see the new row added immeditalety once added.
Some code would probably help to further see what might be wrong, but I would also recommend you to call the following code line directly after you have added a table row.
yourTable.setContainerDataSource(yourTable.getContainerDataSource());
This will update the datasource for your table and force a repaint. If you provide some code maybe more help can be provided
Using IndexedContainer to add new row in table during button click..
Example
Create IndexedContainer
-----------------------
private IndexedContainer getTblTerminals(IndexedContainer container)
{
container.removeAllItems();
container.addContainerProperty("Terminal_Id", String.class, defaultValue);
g_TermialPojo=ws.readAll();
for(Terminal pojo:g_TermialPojo)
{
Object itemId=container.addItem();
strTid=String.valueOf(pojo.getTid());
container.getContainerProperty(itemId,"Terminal_Id").setValue(strTid.toString());
}
return container;
}
//To add indexedcontainer in your table
-------------------------------------------
Example
table.setContainerDataSource(getTblTerminals((IndexedContainer)table.getContainerDataSource()));
table.setImmediate(true);
the SearchFieldDemo works well for me, but has one problem: when you add a new country to the KeywordFilterList through the menu and that new item is on the bottom of the sorted list, then the user doesn't see anything and is unsure if the new item has been added or not.
A solution would be to make the KeywordFilterList scroll to the new item, but I can't figure out, how to do that. I've tried:
void addElementToList(Country country)
{
_countryList.addElement(country);
_keywordFilterField.updateList();
int index = _countryList.getIndex(country);
System.err.println("XXX index: " + index);
_keywordFilterField.setSelectedIndex(index);
}
But this does not have any effect: the printed index is correct and the KeywordFilterList scrolls, but not to a correct spot.
Any ideas please?
Alex
In the sample app you might have noticed the _keywordFilterField.setKeyword(""); line as the first thing they do before adding a new item to the list. This is to guarantee the new item will be visible in the list. Otherwise with some filter applied the list may not display the new item.
So in your code it looks like you don't handle this point. As a result the index you get with int index = _countryList.getIndex(country); may not be the same as it is in the visible filtered by some current keyword list. BTW, to find the index in the visible list you could use the ReadableList which can be got with _keywordFilterField.getResultList().
So the workflow could be as follows:
reset keyword by _keywordFilterField.setKeyword(""); - now there is no filtering applied so the visible list should include a new item.
add a new item to the underlying collection - _countryList.addElement(country);
call _keywordFilterField.updateList(); to refresh the ListField.
to be on the safe side find an index to scroll to by using the collection got by calling the _keywordFilterField.getResultList()
select the new item with _keywordFilterField.setSelectedIndex(index);