How to set the rowStyleClass dependent on data I view? - xpages

Is it possible to add a rowStyleClass to a view dependent upon values in row columns?
At the moment I need to have my code on each column and I'd like to be able to set it on "globally"...
I have tried using viewEntry or assigning the "var" to rowData but without luck. The error's saying that viewEntry or rowData is missing.

This works fine for me (and adds the UNID of the document as styleClass):
<xp:viewPanel rows="5" id="viewPanel1" var="rowEntry"
rowClasses="#{javascript:rowEntry.getDocument().getUniversalID()}">

Related

xpages add value to a binded computed field

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.

Dynamic Fields in xPages

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!

XPages SSJS add options to combo

In SSJS I'm looping through document in a view and I want to add a new option to a hidden combo for each document and once finished then show that hidden combo.
I've tried building an array with value|string and adding that to the getComponent("apm").setValue(myArray), but no luck and how do I grab the combo and make it visible because dojo.byId("#{id:apm}").setRendered(true); gives error about dojo not found, so do I need to include something?
Any ideas?
Add your array to a viewScope var.
In your combo, add a formula value and point it to the viewScope.
After your array is built make sure the combo is refreshed. You can set the rendered property based on whether or not your viewScope var exists.

How to prevent a viewPanel with category filter showing empty rows if filter is not set

I'm having this categorized view displayed in a view panel where the category column itself is not shown. Instead I'm displaying a combobox above the viewPanel where users can select from all the categories available (see screenshot below). The combo is bound to a scopeVariable and is refreshing the viewPanel onChange. The viewPanel has a computed categoryFilter reading from the same scopeVar. That all works nicely.
Now I also have implemented an additional wildcard (*) value in the selection list which (if selected) programmatically sets the cat filter to NULL. This way I'm forcing the viewPanel to show all entries. Again, this works fine, but with the drawback that now the view is showing empty rows where the category entries would be shown normally (in the screenshot you see empty rows above each entry, with 2 entries for the category "edcom GmbH" obviously belonging to the same category; those aren't separated by an empty row):
One way to at least hide those empty rows would be through means of css coding. But I would prefer those rows not being rendered at all.
Can this be done at all using a viewPanel, and how? Or do I have to use other controls like a repeat or a dataTable maybe?
Thanks in advance,
Lothar
One "hack" (an ugly one I admit) would be to change your categorization column from Firma to Firma:"--All--" or Firma:"*" and then instead of setting the category filter to NULL you set it to "--All--" (or "*").
The double category hits the indexer, but should do what you need.
Obviously there's no easy way. So meanwhile I'll stick to this css-style solution:
In the view panel und All Properties - data I set var = "entry". Then, under All Properties - styling I set a programatic value for the rowClasses property:
if(entry.isCategory()){
return "rowStyleHidden";
}
return "";
The style class "rowStyleHidden" hides those rows using
display: none;
Don't know yet how this turns out performance-wise, I'll have to observe this once I implement it in a copy of the real database.
You can also switch to a none categorized view, by having the viewname calculated based on the value in combobox.

Select the current value in a dropdownlist using XSL and SharePoint

I'm using the row edit template below. The problem I have is that the current value is not selected when the row edit XSL template is used. The value defaults to the first item in the list. What is the best way to get the current value to be the selected item in the template below? I thought having DataValueField="{#type}" and DataTextField="{#type}" would resolve the issue, but it does not.
<asp:DropDownList runat="server" id="ff3{$Pos}"
DataValueField="{#type}" DataTextField="{#type}"
__designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'SelectedValue','TextChanged','',string($XPath),'#type')}">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList >
Use DVDropDownList instead of DropDownList. See this MSDN forum post describing the same problem. I've done the same thing in the past and using SelectedValue with DVDropDownList is how I finally got it to work.
Try this:
<asp:DropDownList runat="server" id="ff3{$Pos}"
SelectedValue="{#type}"
__designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'SelectedValue','TextChanged','',string($XPath),'#type')}">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList >
DataValueField and DataTextField are used with data binding, but you are using a specific set of ListItems. Using SelectedValue should set the drop down list to the List Item's current value of type.

Resources