Rails addClass to the most recent data entry - ruby-on-rails

I have a table of names. They are ordered randomly. I would like to highlight the name which has the latest created_at value by adding a class to its table row. So far I came up with creating an invisible column with hidden created_at values and then jQuerying the needed row, but it doesn't sound so good.
A better solution, perhaps?
Edit 1: actually, I would like to highlight the latest added entry for a certain amount of time, ideally only after the name was added. On the next reload/visit all of the rows have to be identically styled.

What about adding a data attribute to each row with the created_at value and then jQuerying the needed row?
<tr data-created-at="#{<%= object.created_at %>}">...</tr>
That way you don't need an additional invisible column, hope this helps

Related

Vaadin grid user column re-ordering and saving per user

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.

Lotus Notes: display fields values in different rows in column

I have a number field called Days and an editable names field called Names ( which allows multiple values ).
Let say that Days=1 and Names=Mike/Rock, Tom/Rock, Dean/Rock.
I want to display them in a column view like this:
1
Mike
Tom
Dean
I tried it with #NewLine, but no luck for me.
I also created a computed (hidden) field test with the following formula as default value:
#Text(Days)+#NewLine+#Implode(#Name([CN];Names);#NewLine)
It seems to be the wanted form for me, but when I just put test in a column default value, it shows nothing.
I appreciate your time.
Try to set your test field to #text(days):Names. This should create a multi-value field (as opposed to a single string which your test formula produces).
Then, set the multi-value separator of the column style to Newline, and adjust the number of rows to match the expected number of values.
In a view we get only one row for one document. Multiple values are therefore shown in one row only with multi value separator.
Eclipse view may perhaps help.

Row numbering in iOS SQLite

In an SQLite table in my app, I need to have a column with row numbers going 1,2,3,4,5 (or to be able to get a row number for every row). Now I delete rows and add rows all the time, so I cant just put a number every time I add a new row, because when rows are deleted, the numbering will get messed up. So is there a way to get the row number, or create a special column that will act as row numbering? If so, how?
If you want this to be reset every time you add and delete rows, should this really be a column in your table?
For example, if you just want to be able to select the 20th row from the table, you can use the LIMIT and OFFSET clauses of SQL to select a particular row, e.g., to retrieve the 20th row from my news table, I could do:
SELECT * FROM news LIMIT 1 OFFSET 19;
Alternatively, if you really want a column with this row number information, you could just add a new INTEGER column type and then write an Objective C method to update the values for that column, and invoke that method any time you delete or insert rows in your result set.
There are a number of ways of solving your problem. You have to explain what you're trying to accomplish for us to help you out. The typical AUTOINCREMENT answer is what we generally use for table keys, but it sounds like you don't want this to be the key of your table, but rather something else.
If you use ROWID which is an auto-incrementing number, you can compute row numbers by selecting all of your data, ordered by ROWID and then using their index in the returned results as their row number. If you have some data model class you're creating, you could pass that in to its initializer.
If that won't do what you want, then how about adding some more details about what you're trying to do. Are you sure you need a row number?
You don't want to go changing all the existing records in your database when you delete rows that make "holes" in your row-umber scheme.
SQLite already supports what you want, with the ROWID. When you make a select query, just specify it to sort on ROWID, and all your returned records will be sorted in their proper order, and you can iterate over them in their order.
See this page: http://www.sqlite.org/autoinc.html
FWIW, there are certainly places where you should prefer direct SQLite over Core Data. However, those are rare cases. In general, reach for Core Data first, and fall back to SQLite only when CD does not serve your needs.
Just use an autoincrement primary key for the table. then there is always a unique identifier you can access a record.

Add field in DataObject in PowerBuilder

I am new to PowerBuilder and I need to add a new column to a DataObject. The DataObject has several fields which retrieves data using select statement. So if I add a column in the select statement I get another field with a name compute_0041 along with the added column field. When i try to remove the compute_0041 field I cannot see any value in the field representing a new column. How do I remove the compute_0041 that gets automatically added?
Thanks
In Datawindow if you accidentally put a 0 or '' in one of the rows in the tab called Computed Columns then these columns may come in. Of course, you can also have a computed column yourself by specifying it there but since it seems you think you didnt do anything and it came up on its own it appears to be an accidental issue.
You can of course check for it by going to the SQL mode and checking for it there. Also, the last tab in the design view it shows the complete generated SQL where you can easily see a select column that is not chosen by you.
Hope the above will aid you to identify the issue. Please let me know if you still have the issue.

<t:datatable> Column value changes - JSF

JSF-2.0 - specific row's(eg: 1st row) column value (eg: 2nd column of a row) need to be changed on change of other column value (eg: 1st column of a row)
I don't know if it is your question but if I understand correctly you probably could render the other column contents based on their id's. I do though think that you need the whole id of the rendered component including the row number of the id. Otherwise just render the whole table.
PLease confirm if this was the question and if this actually functions...

Resources