Sometimes Xpages drives me insane. So many easy things (things that should be easy anyway) are hard.
Simple questions, how do I display multi-value fields with new line in Xpages view Column?
There's ways to do it with computed controls, where you explode the array and add a and stuff like that.
Personally I like to just use a repeat control. Set the field as the repeat value. Add a computed control for the "rowData" and add a if you want a new line between each of them. I'm sure I did this on an early NotesIn9 though I forget which one at the moment.
the key is this. a Repeat control can repeat or "iterate" over any type of array or "multi-value" object.
It's always better and easy to use view control for categorized views rather than repeat controls. To display multi-value field in view column you have to set content type as HTML then just replace commas with <br> tag. And it works exactly as you want.
<xp:viewColumn columnName="$3" id="viewColumn3" contentType="html">
<xp:this.converter>
<xp:customConverter getAsObject="#{javascript:value}">
<xp:this.getAsString><![CDATA[#{javascript:#Implode(value, '<br>')}]]></xp:this.getAsString>
</xp:customConverter>
</xp:this.converter>
<xp:viewColumnHeader value="ColumnHeader" id="viewColumnHeader3">
</xp:viewColumnHeader>
</xp:viewColumn>
Related
In our XPages view controls, we compute a search string (xp:dominoView - xp:this.search) based on dropdown fields on the page, which works great.
But we found that this search returns the results sorted by relevance, and we'd prefer them to be kept in the view's sort order (usually, the first column is sorted ascending).
So, in the Notes client's FT search bar, you can specify this by changing the "Sort results by" flag to "Keep current order (sortable)", and this is also available as URL parameter by adding "SearchOrder=4" - but what would be the correct addition/wording to apply this to a "SELECT" statement resp. the XPages search we use?
The view control has a couple of additional properties that you will need to set; sortOrder and sortColumn.
Also, I believe you need to make the sortColumn sortable on the actual view itself which is on the second tab of the Column properties, "Click on column header to sort".
<xp:dominoView
var="view1"
viewName="your view"
sortOrder="ascending"
sortColumn="your column name">
<xp:this.search><![CDATA[#{javascript:compositeData.searchFilter;}]]>/xp:this.search>
</xp:dominoView>
I'm trying to add the following value to a computed field:
var b = #Subset(#Unique(#DbColumn (#DbName(),"vwNrRegistru",1)),-1);
if (#Elements(b)<1){return 10001; }
else { return (b+1);}
But, I want the computed field to be binded to a datasource field:
<xp:text escape="true" id="computedField1" value="#{Contr.txt_nrcontractcv}">
I would use an inputText, but everytime I open the doc. for editing, the value increments, that's the reason I would like to go for a computed field. How can I achieve this?
You want to take the value from an existing Notes field, then do some calculation on that, then display the result, right?
You might want to bind your comp. field to a scoped var. Then do the basic calculation beforePageLoad and put the result into the scoped var. You can easily control when the calculation takes place, e.g. only for new docs, or on specific times of day or whatever
Create a inputText with style="display:none;", so that it is always rendered*, but never shown on the screen and a 'computed field' (text) that simply is equal to the value of the non-displayed field.
when they chose to label the value in properties as "Visible" they made a mistake. They really ought to have called it "Rendered" in the properties. It might also have been useful for them to have a "Displayed" property to allow you to control the display style, but that would have been mixing too many things.
I have a repeat control that is gathering its data from a view. Displaying in a table is one column from the view. These entries can be variable. For each entry in the repeat control I would like to have a couple of user editable fields (comments and checkboxes). Since the amount and names of entries are dynamic I think dynamic field binding is the way to go. The problem is I have been struggling with it for a few days and have gotten no where.
So in the repeat I have a computedfield displying the value of the column. I was thinking of making the field name for the comments field the value of the computedfield. The datasource would be the same, just the fieldnames would change and be based on the entries in the row.
The previous entries stackoverflow entries about dynamic field binding all list passing custom properties, I still haven't gotten my head around those.
If the value of the computedfield1 = "One" then the datasource/field name for the inputText1 = "document1.One", and if the computedField1 = "Two" then the datasource inputText1 = "document1.Two"
Is this even possible?
I'm a little confused by if you want these to be things you're setting to render at page load or if you want them to dynamically change based on user entered data, but I'll assume it's the former and give you an example.
If I'm iterating through a view in a repeat control, I probably have something like:
<xp:repeat rows="50" var="currRow" value="#{ViewName}" IndexVar="rowNum">
</xp:repeat>
Inside my repeat, I will put a reference to a custom class
<xp:repeat rows="50" var="currRow" value="#{ViewName}" IndexVar="rowNum">
<xc:dynamicRowBinding dataSource="#{currentDocument}">
<xc:this.binding1>
<![CDATA[#{javascript: currRow.getColumnValue("binding1");}]]>
</xc:this.binding1>
</xc:dynamicRowBinding>
</xp:repeat>
What this is assuming is that the document you're binding things to on the XPage is declared as currentDocument, and that there is a column in your underlying view that is calculating the desired field binding for the current row based on the properties and values of that document.
In the custom control, the following exists:
By defining dataSource and binding1 as properties within the custom control, they will be available as compositeData.
Thus, to bind a field using these components, we simply put the following definition in our custom control:
<xp:inputText value="#{compositeData.dataSource[compositeData.binding1]}">
</xp:inputText>
I hope this helps!
One of the better recent enhancements to Notes was the shared columns for views. I could set width. fonts, all kinds of settings and place a shared column in a view. If I needed to say, change a column width, I changed it in one place and it changed across all of my views.
Is there anyway to do this in an xPage view? There does not seem to be a view column so there does not seem to be a way to create a custom control.
Any other ways to do this?
You could create a custom control for every shared column like I did in customer app.
<xp:viewColumn columnName="lastmodified" id="viewColumn4">
<xp:this.converter>
<xp:convertDateTime>
<xp:this.pattern><![CDATA[${javascript:app.getResourceString("language","DATE_FORMAT")}]]></xp:this.pattern>
</xp:convertDateTime>
</xp:this.converter>
<xp:viewColumnHeader id="viewColumnHeader4">
<xp:this.value><![CDATA[#{javascript:app.getResourceString("language","COLUMNHEADER_LASTMODIFIED")}]]></xp:this.value>
</xp:viewColumnHeader>
</xp:viewColumn>
I am using a ViewPanel to show a categorized view. This view has 4 columns of categories. There are 3 additional columns that are totaled.
I want to open this view so that the first 3 categorized columns are expended and the 4th one is collapsed.
Is there some type of SSJS / CSJS that I can add to the view that can do this?
I didn't see an option to expand/collapse a column upon opening the view in the Properties of the viewPanel.
I tried using the collapse option on the back-end view but that has no effect on the Xpage side. I tried hide detail rows, but they show up anyway.
To do this, just change the expand level of your datasource:
<xp:this.data>
<xp:dominoView var="view1" viewName="NameOfYourView" expandLevel="4" />
</xp:this.data>
EDIT:
You can even control this by adding a simple URL parameter: nameOfXPage.xsp?expandLevel=3
Have a nice day
Sven