Xpages Extlib dataView control sets "display:none;" style when column has empty value - xpages

I have a xpage with Extension Library DataView control. I have defined several extra columns there.
<xe:dataView id="dataView1"
<xe:this.data>
<xp:dominoView var="vMyView" />
</xe:this.data>
<xe:this.summaryColumn>
<xe:viewSummaryColumn columnName="$DateFrom"
columnTitle="Date From">
</xe:viewSummaryColumn>
</xe:this.summaryColumn>
<xe:this.extraColumns>
<xe:viewExtraColumn columnName="$DateTo"
styleClass="hidden-xs" headerStyleClass="hidden-xs" columnTitle="Date To"
style="hidden-xs">
</xe:viewExtraColumn>
<xe:viewExtraColumn columnName="$Information"
columnTitle="Information">
</xe:viewExtraColumn>
</xe:this.extraColumns>
</xe:dataView>
My view data source contains same cells where information is empty. Those cells are rendered with style="display:none;".
How can I avoid this attribute and display those empty cells? I'd like not to change my view to fill empty cells with i.e. "-" char

An empty column value gets rendered with style="display:none;":
You can avoid this if you add a custom converter to your column definition and replace an empty value by a space:
<xe:viewExtraColumn columnName="$Information"
columnTitle="Information">
<xe:this.converter>
<xp:customConverter>
<xp:this.getAsString><![CDATA[#{javascript:value == "" ? " " : value}]]></xp:this.getAsString>
<xp:this.getAsObject><![CDATA[#{javascript:value}]]></xp:this.getAsObject>
</xp:customConverter>
</xe:this.converter>
</xe:viewExtraColumn>
It gets rendered to a "normal" grid cell without display:none then:
The code for getAsObject doesn't matter as long as the cell is not editable. So it's OK to just leave the value as it is.

Instead of using a converter to "fake" some content, you could also adjust the css. Just implement
.lotusTable TD {
display: inline !important;
}
in a style sheet resource used in your custom control(s).
So you also won't have to apply a converter to every potentially empty column.

Related

Setting empty string in headerText attribute

I have JSF data table and only one column has column header.
I need to hide the column with header text based on the condition and when I do that the entire header row shrinks because the other columns don't have header text.
To prevent this, I need to set 'empty' string and I tried a few tricks but nothing seem to work.
<p:dataTable ....>
<p:column headerText=" " >
How do I set empty string headerText attribute?
Thx in advance.
Depending on your Primefaces version you could use this code to force the creation of the html element
<p:dataTable ....>
<p:column headerText=" " >
With early version this should create the div but make it very small, so you can add css style to adjust to your wish, something like
.ui-datatable thead th {
min-height: xx px;
min-width: yy px;
}
I think you can solve your problem event with only the second part, so only with css.

How can I get a selector to do a partial lookup on any field in the list

I have a selector that is selecting cases among several other fields, as follows:
[PXSelector(typeof(Search2<CRCase.caseCD,
InnerJoin<PMProject,
On<CRCase.customerID, Equal<PMProject.customerID>>>,
Where<PMProject.contractID, Equal<Current<EPTimecardDetail.projectID>>>,
OrderBy<Desc<CRCase.caseCD>>>),
typeof(CRCase.caseCD),
typeof(CRCase.subject),
typeof(CRCase.createdDateTime),
typeof(CRCase.caseClassID),
typeof(CRCase.status),
typeof(CRCase.contactID),
typeof(CRCase.ownerID))]
When the selector is open, the search bar will only search on the first field - the CaseCD. If I type part of the Subject field text, I want it to show, as in other lookups, the entries that have that snippet of text in them. i.e., if I know part of the Subject field, I want it to filter or show entries filtered on that bit of text I enter.
Is there a setting in the PXSelector attribute that allows this, or would it be on the aspx page for the Selector?
In the past (unless there is something new) we set the FastFilterFields in the page.
Ex from project entry on contract cd (page PM301000):
<px:PXSegmentMask ID="edContractCD" runat="server" DataField="ContractCD" DataSourceID="ds" AutoRefresh="True">
<GridProperties FastFilterFields="Description, CustomerID, CustomerID_Customer_acctName" />
</px:PXSegmentMask>
Each field listed in FastFilterFields will be searchable in the selector.
Use of FastFilterFields will apply to PXSegmentMask or PXSelector.
Another example showing selector:
<px:PXSelector ID="edReceiptNbr" runat="server" DataField="ReceiptNbr" AutoRefresh="true">
<GridProperties FastFilterFields="InvoiceNbr, VendorID, VendorID_Vendor_acctName">
</GridProperties>
</px:PXSelector>

Xpages: Validation using java bean with multiple instances of a custom control

I have a custom control for an editable field, and validation is done via a java bean. I want to set the isValid() property to set bootstrap styling like so:
However, this does not work if I place the cc on a page more than once, because I am searching on the component's ID to set the Valid property.
I need to either compute the id of the field in the CC, or do something else like this post describes.
I believe I can compute the ID of the text field like so:
<xp:inputText
id="${javascript:compositeData.fieldName}"
type="text"
loaded="${!empty compositeData.placeholder}"
required="${compositeData.required}"
disableClientSideValidation="true">
<xp:this.attrs>
<xp:attr
name="placeholder"
value="${compositeData.placeholder}" />
</xp:this.attrs>
<xp:this.binding><![CDATA[#{javascript:compositeData.dataSource[compositeData.fieldName]}]]></xp:this.binding>
</xp:inputText>
However, there are a few places where I need to compute the component, such as
<xp:this.styleClass><![CDATA[#{javascript:"form-group" + (getComponent("inputText1").isValid() ? "" : " has-error" )}]]></xp:this.styleClass>
I have to replace the "inputText1" with the computed ID, but cannot figure out how to do so.
Is there a better/easier way?
Why would you not use the compositeData.fieldName everywhere you reference the id?
<xp:this.styleClass><![CDATA[#{javascript:"form-group" + (getComponent(compositeData.fieldName).isValid() ? "" : " has-error" )}]]></xp:this.styleClass>

XPages inputTextArea is not editable

When i use multiLine editbox (shown in FIRST ONE) It cannot be editable If the document is in editMode.
But SECOND ONE is editable. My point is if use formula at the value of inputTextArea It can not be editable.
I could not find what it is that i missed?
FIRST ONE:
<xp:inputTextarea id="muvName" rows="2" cols="70"><xp:this.value><![CDATA[#{javascript:#Implode(document1.getItemValue("muvName"))+ #NewLine() + "C/o";}]]></xp:this.value></xp:inputTextarea>
SECOND ONE:
<xp:inputTextarea id="muvName" rows="2" cols="70" value="#{document1.muvName}">
</xp:inputTextarea>
Use the property defaultValue to define a default value:
<xp:inputTextarea
id="muvName"
rows="2"
cols="70"
value="#{document1.muvName}">
<xp:this.defaultValue><![CDATA[#{javascript:
#Implode(document1.muvName)+ #NewLine() + "C/o"
}]]></xp:this.defaultValue>
</xp:inputTextarea>
and use property value for binding a document's item (or a scope variable) to the editable field. value has to be an object to which XPage can write the submitted content to.
In your first example you calculate a string and it's impossible to write something back to a calculated string. That's why the field is read only.
Update:
If you want to correct document field's value before editing then use a custom converter instead:
<xp:inputTextarea
id="muvName"
rows="10"
cols="70"
value="#{document1.muvName}">
<xp:this.converter>
<xp:customConverter
getAsObject="#{javascript:value}">
<xp:this.getAsString><![CDATA[#{javascript:
if (!value.endsWith("C/o")) {
value += #NewLine() + "C/o";
}
value
}]]></xp:this.getAsString>
</xp:customConverter>
</xp:this.converter>
</xp:inputTextarea>

How can I initially hide columns in a p:dataTable with p:columnToggler

I'm using PrimeFaces v.5 with this version a new component is released that ColumnToggler, when view is rendered, refreshed all checkbox are checked as a default operation.
What I need to do is;
to uncheck some columns when I initialize the view,
make p:columnToggler remember checked and unchecked options when a refresh operation occurs on p:dataTable
In Primefaces 5.2 you can set the p:column visible attribute to false
<p:column ... visible="false">
You can ofcourse use EL in the visible attribute by colum index (reordering becomes more difficult)
<p:column ... visible="#{visibilityModel.visibleList[1]}">
It hides the column at the beginning depending on the return value and you can show/hide the column through the columnToggler checkbox
By using the ajax toggle event
<p:ajax event="toggle" listener="#{viewBean.onToggle}" />
You can update the state of the visibilityModel server side
public void onToggle(ToggleEvent e) {
list.set((Integer) e.getData(), e.getVisibility() == Visibility.VISIBLE);
}
See this PrimeFaces blog entry for full example to actually keep/store the state of the visibility server side so it can be reused later
The best solution depends on the PrimeFaces version you are using.
PrimeFaces >= 5.2
See the other answer in this question.
workaround for < 5.2
You need to solve the first problem manually by overriding Primefaces' own ColumnToggler.prototype.render() function
first add styleClass="not-show-at-start" to your column that you want to insvisibe at start to access in javascript render() function;
<!--This column will not be shown at start-->
<p:column headerText="Cloumn to hide initially" width="70" styleClass="not-show-at-start">
<h:outputText value="#{entityVar.nmProcessOwner}" />
</p:column>
<!--This column will be shown at start-->
<p:column headerText="Column to show initially" width="70">
<h:outputText value="#{entityVar.nmProcessOwner}" />
</p:column>
secondy create a javascript file and paste code below in it, this function will re assign render function of ColumnToggler
PrimeFaces.widget.ColumnToggler.prototype.render = function() {
//variable for creating id referance for each checkbox in ColumnToggler
var id=0;
this.columns = this.thead.find("> tr > th:visible:not(.ui-static-column)");
this.panel = $("<div></div>").attr("id", this.cfg.id).addClass("ui-columntoggler ui-widget ui-widget-content ui-shadow ui-corner-all").append('<ul class="ui-columntoggler-items"></ul').appendTo(document.body);
this.itemContainer = this.panel.children("ul");
for (var a = 0; a < this.columns.length; a++) {
id++;
var b = this.columns.eq(a);
$('<li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div id="cb'+id /*creating id for each checkbox for accessing later*/+'" class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>' + b.children(".ui-column-title").text() + "</label></li>").data("column", b.attr("id")).appendTo(this.itemContainer);
//access clumns using class reference(not-show-at-start) created in jsf page
if(b.hasClass( "not-show-at-start")){
//access checkbox using id attribute created above and uncheck it
//this will hide columns that have "not-show-at-start" class
this.uncheck($('#cb'+id));
}
}
this.hide();
}
An alternative solution could be to set directly the checkbox you want to uncheck after you load the page. It's a less elegant solution but it works. I did it this way:
<h:body onload="javascript:
$('.ui-chkbox-box')[18].click();">
By this way, after loading the page, javascript hide the column referenced by chechbox number 18 but the checkbox is still present on the columnToggler for the user to check it and show the column again if he wants to.
Greetings
Complementing Damián answer:
$(function() {
$('.ui-columntoggler-items .ui-chkbox .ui-chkbox-box').click();
});
This will do the job, clicking the columntoggler chkbox after page load..
#Edit
You should set as toggleable="false" the columns you don't want to hide (always displayed)
Reason: if you use the javascript method to "override" primefaces toggler, sometimes the datatable column shown can be displayed wrong in the layout (out of the table size, for an example, like happened with me), that's why i decided to use the method described above..

Resources