repeat control from categorized view - xpages

I have tried to get the column values in repeat control from Categorized view in xPages,that time i got the column values are coming with single row,and the same row repeated
How to get the column values in "repeat control from categorized view"?
Thanks

I had a situation where I had to drill down from a much larger view and repeated the info back out with the following.
View is categorized in first column by what I'm drilling down by. I achieve this in the XPage/Custom Control by defining the view as a source in the data tab, then select "filter by category name", bind my repeater to that view data source, and compute the value I'm drilling down.
Then in my repeated table, each of my computed fields for each of the column entries read like:
rowData.getColumnValues()[1]
Adjust for your other columns by position with the array modifier after your getColumnValues method. This is not an elegant solution, but worked for my needs. Hope this helps if it's what you're looking for.
[Update]
It's worth noting that doing this can potentially create a memory handle for any DateTime objects which may be returned in the entirety of the getColumnValues method. If you're going to use this approach, I strongly recommend getting a handle on the column values separately, so you can perform a session.recycle(colVals); on them to prevent any memory creep.
[/Update]

Related

How to identify notesView columns that have column totals defined for them?

I have several views that have 'column totals' defined in some columns of these views. The totals can be in different positions in each view. I'm looking a for a fast, reliable way of identifying which columns have totals before I scan these columns and views.
Ideally, I want a 'isTotal' property on the column defintion (NotesViewColumn), but that property is not defined/available.
I can see that totals in the ColumnValues array does return a 'double' datatype where a column exists, but I can only see this once I've started scanning the data in the view, and I want this detail before I start looking at the data. (For information, the ColumnValues for a category notesViewEntry is an array containing: strings for cat columns, 'empty' for untotalled fields, and doubles for totals).
I can (of course) hard-code this detail somewhere, but it seems archaic to have to do this. I can 'getFirstDoc' to work out the ColumnValues in a 'pre-loop' check, but this seems 'wasteful'.
PS: I have seen something called 'ColumnValuesIndex' but this appears to be an undocumented feature which I would prefer not to use. However, if there were an 'isTotal' undocumented feature - I'd be ok with it!
The only solution I can think of to do this before you scan the data is to export the view design to DXL, then check the DXL for attributes or elements that specify whether each column shows totals.
I'm assuming view columns in DXL have an attribute or child element for this purpose. I haven't checked.
In case you've never done anything like this, using a NotesDXLExporter with either a NotesDOMParser or a NotesSAXParser, you can export selected design elements to in-memory DXL and programmatically analyse it.
As outlined in the original post, looking at the ColumnValues of a NotesViewEntry (NVE) on a category row does provide an array of values you can use to determine if any specific column is either a category string, empty, or a total. The totals have a datatype of double so stepping over the columns in a loop can easily flag the totals.
If the view has categories, then the first NVE in the view will give these details. A simple 'NotesView.GetFirstEntry().ColumnValues' will return the array. If the view has totals, but not categories, you can 'GetLastEntry' for the totals row at the bottom of the view.
Reading the totals is then just a case of looking for category rows (nve.IsCategory) and extracting the totals from the nve.ColumnValues.
Performance is reasonable and can be made a bit quicker by building a booleans array pre-loop of where the totals exist.

Excel: Averaging the values from a set of rows, but only include them if they have a specific value in a column

I'm looking for help dynamically averaging the column values of every item in an Excel table that has a given value in one of its columns. Specifically:
I have an Excel sheet where each row represents an entity in a video game I am working on, and each column is a numerical value for different attributes on these entities. Movement Speed, Health, Attack Damage, etc. Each of these rows also has a column where I tag the row with the name of the class that this entity is a part of: "tank", "support", etc. This table has roughly a hundred items in it, and is likely to grow to two or three times that size.
It looks something like this:
What I would really like to do is have, on a separate tab, a table where each row represents one of the classes, and shows the average value of all of the entities that have that class in their "group" column. And I want it to automatically include new entities of that class as they are added to the first table.
It would look something like this, where these values are automatically generated from the data in the first table (I have no problem manually entering the class names, I just need the numerical data to be driven):
I imagine that the solution will be a complex, nested pile of VLOOKUPs and MATCHes and other Excel functions, but I am not really sure how to accomplish this. I didn't even know the proper terminology to search for existing answers to this question, so I hope that it isn't too redundant. Thanks very much for any advice you have!
Version: I am using Excel 2013.
I think all you need is a pivot table. (its been around since the 90s?) - and very useful!
there are lots of ways of refreshing etc depending on where the data comes from
http://office.microsoft.com/en-us/excel-help/pivottable-reports-101-HA001034632.aspx

How to Sort View control by Lookup column

I have two forms that are related and I would to combine them in a view control. Not that difficult. This is for a "1 to Many" type scenario.
Say I have a customer view with the columns customerID and Customer Name. Then I have a view showing the "many" documents that has the columns masterCustomerID, orderNumber, orderDate.
On the XPage I create a view control of the many documents and add the columns masterCustomerID, orderNumber, orderDate. Then I add a column in the front to do a DbLookup to pull in the actual name of the customer. Nothing too fancy really.
My question is, in this situation, where the lookup column is the FIRST column. What are the strategies to sort the view column by that column. By default it would sort by the Key Value in the order view which is likely different then the Name values.
I'm not averse to using repeat controls if that would be easier.
My first thought would be to employ TreeMaps somehow, but I don't know if that's practical in the event that there might be a LOT of documents. Maybe there's something I'm missing...
Any advice would be appreciated. Thanks
Use view with (Customer name, Customer ID) structure as main view. Then based on Customer ID populate other columns by lookup from view with structure (Customer ID, Order ID, Order date). Hence it is 1:N relationship, you can't use single view component, but two nested - repeat inside view column would do.
I hope you are aware of performance impact (orders looked up for every customer row), so don't try to show too many customers at once.

Sort Column Total

I have a view with column totals.
What I want is to sort the totals-column in a Xpages-view or repeat-control.
I am able to get the totals to display but cannot sort them.
Any suggestions?
Not very clean. I wouldn't do that in production - for performance reasons - it's a brute force solution, but it should work for fair amount of categories (up to few hundreds).
Assume the view can be used for category lookups (similar to show single category). Then all you need is list of categories in correct order - based on totals and not alphabetical order. Therefore, in first cycle, loop through all categories (use NotesNavigator with cache) and store them as pair of values - (category, totals). It may be Map[String,Double] or Set[Category] where Category is POJO with category and totals attributes. In both cases you will need your own Comparator. If your categories are hierarchical, use only top level category (sorting of tree structure is more complicated).
For example:
Australia (5)
Brazilia (10)
Chile (7)
will sort as
Brazilia (10)
Chile (7)
Australia (5)
Cache this collection in viewScope (assuming totals are "static" for short period of time, user will need to reload the page to get updated data).
Feed this collection to repeater with simple data table (or view or repeater) showing only selected category.
GUI will be a bit odd with pagers (pager for categories and pager for content of category), but you will handle this, I hope.
It's probably better to ask can this type of sorting or resorting be done in Notes rather than can it be done in XPages. If it can be done in Notes then you should be able to do the same in XPages - sometimes automatically.
XPages can only do so much with the view datasource. So if the datasource can't sort the categories by the totals then you won't be able to do this in XPages. At least not out of the box.
You might be able to do something with repeats - doing a lookup of the datasource, retrieving all documents under a certain category that has the highest total before moving on to the next category in the sequence - but it likely to become pretty complicated and not worth it in the end.
Sorry if it's not the answer you're looking for.
I will try to clarify it.
There is an categorized view. Category is for example Company name.
In the view is a column with totals, so the category has also a total.
The wish is that this categorized view will show the company category, who has the highest total at the top of the view, without losing the categorization

grouped UITableView to generate block rows

I want each row of my table view to appear, as it's own independent block, a little like how the Twitter app has on the Discover section (they have the top 3 trending word as 3 blocks.
I am trying to recreate this and the route I am trying to go down is having my table as a grouped tableview but instead of treating each row as a row of one section, I will treat a row as a section, thus generating blocks, each block will have only 1 row.
It sounds like a hack, I'm sure it's not the way to be doing it, but can anyone lend some tips about this kind of setup ?
Also I am using NSFetchedResultsController and I need to specify I want my objects ordered by date, but the section be defined by a unique id which would allow me to generate a section per row. I am not getting any luck with my fetch request either, so I guess this is 2 questions.
Although if I am wrong with the first part, the second becomes irrelevant.
Thank you.
I would not do it this way. Looking at the Twitter app, I have no doubt that this is a grouped table view, and the block sections use the first row as the title and a second row with a bigger row height for the content.
You can adjust the sections and rows as needed in the table view datasource methods, based on what comes back from the NSFetchedResultsController. Only caveat is that you have to be careful when you use the index path to refer to the core data objects.
The design of the Twitter "blocks" suggest a grouped table view, in fact I did manage to achieve this with a plain table view I just needed to be careful with the borders and background colours behind the cells...

Resources