Vaadin grid user column re-ordering and saving per user - vaadin

How do people tend to let users re-order the grid columns and save that ordering for later?
The only way I can think of to do it, at least in Vaadin 7, is:
Listen for column re-ordering via addColumnReorderListener(…)
When re-order triggered, if user initiated, get columns from getColumns() and save to DB with any identifying information
When pull Grid back up, read grid ordering from DB and apply the same order with setColumnOrder(columns)
So is there a better way to do this? I just checked the Directory, could not find anything obvious to make this easier. Just looking for how others have addressed this user requirement. If Vaadin 14 already supports such actions a little easier, that would be good to know as well, as it might give me some ideas on how to get that ability short term before I can upgrade to Vaadin 14.

For a more customizable grid you can (in addition to what you've already done) add a button that opens a dialog that lists all possible columnnames, together with a checkbox.
Unchecking the checkbox removes the column, checking the checkbox adds the column.
Even more comfortable is when the dialog lists all available columns in a Grid with draggable rows and editable checkboxes, so that the user can show, hide and sort all columns in one place. After that you have to reorder all columns by calling grid.setColumnOrder.

Just so people know how I solved this issue, based on the comments:
When load data into Grid, first check database for columns of this Grid/user combination. If find such a column order, call setColumnOrder(userColumns).
Added 2 buttons to top, one to save column order, one to reset it.
"Save" button only enabled after moving at least one column.
"Reset" button only enabled if at least one column was moved. One column was moved either because of the DB, or because user JUST moved a column.
On save, save to DB. On reset, clear from DB, and reset Grid to original column order.
We chose not to save the column order each time they changed the order, directly in the addColumnReorderListener, because we realized sometimes users might move columns around temporarily, and one really want to save that column order for the future. That said, the saving inside the addColumnReorderListener worked well.
We don't currently need to save the column sizes, as suggested by #Simon Martinelli, but we are keeping it as an idea for the future. I fully expect it would work.

Related

Can filters hide invisibly?

I'm very new to Tableau, just creating my third very simple Viz. By adding and deleting filters, I seem to have managed to create an invisible filter and I don't know how to get rid of it. I deleted the dashboard and all sheets but the filter persists somewhere.
In the data-source tab, when I describe the "mix" field it has 6 discrete values as it should. When I look at the table I can see 6 discrete values. But NOW when I create a brand new first sheet and don't do anything else but look at "describe" for "mix" in the list of fields, "mix" only has one value. If I drag it to the screen it shows up with that one value.
Any ideas where I might find this hidden filter?
Thank you.
Aha. I hadn't realized that making an extract of the source data (so that I could put the Viz up publicly) was silently filtered by the filters in place on a screen.
So, unknown to me, my source-data had become "pre-filtered" and of course nothing I could do at a screen level after that could remove that filtering.

How to highlight changed cells when updating a DBgrid?

Let's say I am showing stock prices, or sports scores, or movie attendance or something.
Periodically, I will refresh the grid by Close() and then Open() of a query linked to its associated datasource.
I know how to owner draw a cell with OnDrawCell() - what I can't figure out is how to know if the new value is the same as or different from the previous value for a given cell.
I suppose there are two use cases here, one where the number of rows is fixed and they remain in the same row order and one where rows can change (insert/delete or reorder).
For the former, I can take a snapshopshot before updating and compare after the update, but that might be a lot of data. I am not sure if I want to restrict the operation to the currently visible rows. I think that a user might want to scroll down and still be notified of any which have changed during the last update.
For the latter, I am stumped, unless, of course, each row has a unique key.
How can I do this (efficiently)? A solution for TDbGrid would help everyone, a solution with TMS Software's TAdvDbGrid would be fine by me (as would a (preferably free) 3rd party component).
TDBGrid reads the data currently contained in its assigned dataset. It has no capacity to remember prior values, perform calculations, or anything else. If you want to track changes, you have to do it yourself. You can do it by multiple means (a prior value column, a history table, or whatever), but it can't be done by the grid itself. TDBGrid is for presenting data, not analyzing or storing it.
One suggestion would be to track it in the dataset using the BeforePost event, where you can store the _oldvalue of a your into a LastValue column, and then use that to see if the value has changed in your TDBGrid.OnDrawColumnCell event and alter the drawing/coloring as needed. Something like if LastValue <> CurrValue then... should work.

add a checkbox to each row inside an XLSX, then delete on upload

So ATM the user can download an xlsx document, and add new records to it, upload it to the application which updates the DB(with the new records)
I would like to put an option in the excel doc. like a check box (at the beginning of each row) or something like this which, if selected when the doc is uploaded again, it will delete that record from the DB.
I know the logic and how to delete the record but im not sure how to include something like a check box and relate it to each seperate row?
Any one have any ideas?
thank ye
You can use Checkboxes, although you would need to use an "xlsm" (macro-enabled workbook) to insert them. (you could do it without vba but manually inserting checkboxes and configuring them isnt going to be much fun)
Checkboxes can be "linked" to a cell in your workbook. You'd need to add a Checkbox to each line, and set the linked cell to another cell on that row (preferably all the same column).
You could also make it a lot simpler by doing away with the checkbox and just having a column that you set to true (or any non-empty value) and have your application interpret that to delete the records.
Both methods require you to have an extra column.
Any method will require either an extra column or another sheet with a single column to track the state of each line.

What are hidden fields in a Clarion .TPS file?

I am looking at extracting some data from a Clarion .TPS file and I have been using the TopScan Application to open them.
When I look at the tables there are lots of hidden fields.
Are they just protected fields i.e. to stop someone from seeing the information or are they something to do with the indexes?
Also would using the ODBC driver reveal what they are?
Reards
The first time you open a TPS table using Topscan, it only shows the first few columns (15 I think) and the rest are set as "hidden". This is only a feature of Topscan, not a developer or technical restriction.
To view them, click on the menu Column » Show/Hide.... It will show a dialog with all the columns in the table, click the button Select all and OK and all columns will be displayed.
After you close the table, a new file tablename.SCN will be created, it saves the visible/hidden status of the columns and any other changes you make the view (column width, position, picture, etc.)

How to handle Append Only text fields in a Sharepoint DataSheet view?

We've created a Sharepoint site to track a process. Eventually we're going to make a workflow out of it, but in the meantime there's a list we all have to look at which lists the various dates each piece is supposed to be finished.
So basically My group needs to see and update columns X, Y, Z and Comments while ignoring the other 30 billion or so columns. Which is great in datasheet view because we can easily view our columns, and update them right there without drilling into the item and browsing through all the other crap we don't need.
The problem is the Comments field, in which we really need to see the last actual comment made. Unfortunately whenever anyone saves the record the field is updated with a blank value (unless they entered a comment) and the last actual comment is lost unless you drill into the item.
Is there some way to get the Datasheet view to show all the entries?
I should also note that I know very little about Sharepoint 2007... so detailed answers would be nice!
Append-only comments are implemented with the version mechanism, so in the Datasheet View you're seeing every row update as a new version of the item with a new comment. In normal data views this logic is handled by the AppendOnlyHistory control. I don't know of any way around this behavior for views that aren't history-aware like the Datasheet.

Resources