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

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.

Related

How to Ignore selected rows when filtering using floating filters in ag-grid?

I'm currently working on a project that uses ag-grid in Angular.
We have a table that displays some sort of data and it's possible to filter this table using some textbox floating filters above the table for every column.
Every row has a checkmark in the beginning that can be used to select this row.
The goal is to figure out a way to not filter out the rows that have been selected by the user. The rest of the rows should get filtered as normal.
Is there an easy way to implement this?
I've been looking trough the documentation and it seems like I will have to write a custom filter component, but I'm not sure where to start. Do filters even have the capability to check if a row is selected or not?
So I figured out an easy way. I created a new simple class:
export class IgnoreSelectionFilter extends TextFilter {
doesFilterPass(params: IDoesFilterPassParams): boolean {
if (params.node.isSelected()) return true;
else return super.doesFilterPass(params);
}
}
I use this class as the "filter" component for every column where this functionality is required. This new class behaves exactly like agTextColumnFilter, but first it will verify if the node is selected or not and ignore it if it's selected.

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 to implement new item of sap.m.Table in Fiori?

I want to implement new item(row) in sap.m.Table. In Add Items section of Fiori guideline, it looks like this:
Here is my Demo
I have three questions:
How to add the new row to the first item of the table?
How to "highlighted it with a visual indicator"? (the left blue part in design)
Why addOneRow function did not work before setModel? Is it because data binding refresh the table or sth.?
1- The way I addressed this problem in several project is by using 2 tables : first tables only contains one fixed row and the second one is binded to an array. When clicking the 'add' button in the first table it resets the first table content and adds an item to the second table binding
2- the hightlight property is on the items. example:
<ColumnListItem type="Detail" highlight="Error">
if you use my solution from #1 you might use it only on first table
3- you're totally right, this is also why you should put your 'addOneRow' in the 'onAfterRendering' callback to make sure your last row (that you likely always want) is always displayed.
(btw if you use solution from #1 you simply dont need it anymore)

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).

GWT CellTable : Add / Delete a row in a CellTable

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();