How can I make a sap.m.Table sortable by drag and drop? - 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).

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

scala, swing : make a table scroll to the last row non empty

I would like to be able to add a row in a table, to achieve this I thought to a button near the table, with the caption "New/Update". if no row is selected, then clicking on this button makes the table "scroll" to display the first empty row, then the person enter the informations in this row, and a second click on the button stores the new row.
But I need to make the table scroll, how can I do this?
I searched on internet and found this : here, but it is in Java and I did not find the scala equivalent to getCellRect method.
please note I did not used a model for the table.
If there's a method that isn't implemented in the Scala version, you can use peer to access the underlying Java Swing version.
So you should be able to access the method in your question, if you have a Table t, using t.peer.getCellRect.

How to remove the sort indicator in GtkTreeViewColumn keeping the column sortable?

I know it's a bug that is considered not an issue but when you have many columns that you still want them sortable, all displayed without the need to scroll right and left and the sort arrow indicator is not so important. What are available workarounds?
I found it can be done by not applying set_sort_column_id to the treeview column. We must do it programatically through using set_clickable method to the the column that you don't want an arrow to be displayed in its header, then using signal_connect to the clicked signal and bind it to a function which will use get_sort_column_id of the model to get the current sort order whether GTK_SORT_ASCENDING or GTK_SORT_DESCENDING then apply the reverse sort order using set_sort_column_id on the model.