GWT CellTable : Add / Delete a row in a CellTable - gwt

Is the GWT CellTable designed to only display records and update the existing ones.
Can one add and delete a record from a CellTable, any pointers to a stable solution.
Thanks

You can add and remove data rows by manipulating the model object backing the CellTable display.
ListDataProvider<OrderLineWeek> model = new ListDataProvider<OrderLineWeek>();
model.addDataDisplay(myCellTableInstance);
You can then access the list through model.getList(), but you must call model.refresh(), or table.setRowCount(model.getList().size()) if you have added or deleted any rows.
Hope this helps.

ListDataProvider.getList().remove(index);
DataGrid.redraw(); // to refresh
to add, create object then assign data to this object,
ListDataProvider.getList.Add(object);
DataGrid.redraw();

Related

Add empty rows in a tableviewer

I want to use a "Add" button to add empty rows in the table using table viewer. After adding a new row, the user can edit it. How can I implement this design? Thanks!
You should add the rows to the data that your content provider returns in the getElements method using something that the label provider will show as empty. You then call refresh on the table.
For editing you will use the normal EditingSupport and make sure it can deal with empty entries.

How can I make a sap.m.Table sortable by drag and drop?

I would like to make my sap.m.Table manually sortable, so I can sort the rows of my table by drag and drop. I have tried using the jQueryUI sortable() method (it works on lists!), but if I use it on the table it makes the whole table draggable and if I use it on a ColumnListItem I can sort the content of the ColumnListItem, but not the ColumnListItems listed in the table. Does anybody have an idea what else I could try? Or maybe even have a solution to my problem?
I am thankful for all the help I can get!
Your problem is that you only want to make the table rows (<tr>) draggable. Therefore you need to pass the parent element to jQuery.sortable. Try something like this in your controller:
this.getView().$().find(".sapMList.myClass tbody").sortable();
Whereas myClass is a style class you added to your control (so that only THIS table instance will be affected).

How to add a custom row for adding data to ember-table?

I would like to add a custom row at the bottom of an ember-table so that it will allow the user to insert new rows to the table. Which approach should I take? The idea is similar to the one asked here but using a fixed row and ember-table.
I'd suggest extending Ember Table to override footerContent:
import Ember from 'ember';
import TableComponent from 'ember-table/components/ember-table';
MyTable = TableComponent.extend({
footerContent: ...
});
You'd then override Ember.Table.Row with a custom row, and put that into footerContent. You could define an extra action on that row which grabs the row's data and adds it to content backing the main table. (You'd need to pass a reference to content into your custom row).
You can do the same thing by overriding bodyContent, but I think using a footer is perfect for this purpose, and I increasingly think overriding bodyContent is a bad idea.

GWT CellTable - Column Sorting is reset after ListDataProvider refresh

I'm using a CellTable, which is fed data via a ListDataProvider. Currently a user can sort the CellTable columns, then click a row. Clicking a row pops up a stand alone editor next to the cell table. When the user clicks "save", the code updates the employee in the ListDataProvider, then calls:
listDataProvider.refresh();
This works, but the column sort is reset. This is not acceptable because it resets the column sort that they have used, and it is a pain to have to resort the columns after every save. Is there some way to tell the CellTable to keep its current column sort when refresh is called?
Your need to call ColumnSortEvent.fire(dataGrid, dataGrid.getColumnSortList()); if you want to recover the sort order after refresh. I think it should work the same for CellTable.
This is how we refresh the DataGrid:
selectionModel.clear(); // SingleSelectionModel
dataList.clear(); // List<Data>
dataList.addAll(newData); // List<Data>
dataProvider.flush(); // ListDataProvider<Data>
dataProvider.refresh();
ColumnSortEvent.fire(dataGrid, dataGrid.getColumnSortList()); // DataGrid<Data>
Ended up adding a listener on the column sort, and sorted the list in code rather than allowing the CellTable to handle the sort. This kept the sort order. I'd post the code, but I no longer have access to the code base.

is anybody have idea in gwt celltree as a celltable column??? Because GWT does not have tree table

I want to use cell tree as a cell table column. because GWT does not have tree table. In my current project, I have to make feature like item and it's subitem in cell table. so it is not possible without tree table
If any body have idea of this then please help to make it possible.
GWT 2.5 (to be released in a month or so) will add a CellTableBuilder that will let you generate additional rows; handling events on them will allow you to show/hide "child rows", mimicking a tree table.
Alternately, and withou waiting for 2.5, you can have your cells in a CellTree render columns (use a CompositeCell for flexibility and reuse). AFAICT thus is how Google Groups shows the unread count and menu for your favorite groups.
I am trying build tree table with tree widget plus flextable only. With the help of both, I am able to create custom tree table widget.
http://examples.roughian.com/index.htm#Widgets~Tree
finally..I able to create custom tree table as requirement.