I created an XPage and added a view control to it, based on a Notes view in which some of the columns are based on formulas rather than fields (for example, #If(nomprov="";cifprov;nomprov)). As a result, the column name on the XPage is a number preceded by a dollar sign, such as $14. View columns that are field based do not show such behavior (the column name on the XPage is the name of the field).
This did not harm on any way, but now I am trying to implement full-text search on the XPage view, and the search on $* columns is not working. This is the definition of one of these columns on the page source:
<xp:viewColumn id="viewColumn3" styleClass="columna"
columnName="$14">
<xp:viewColumnHeader value="Proveedor"
id="viewColumnHeader3" styleClass="cabecera" sortable="true">
</xp:viewColumnHeader>
</xp:viewColumn>
And this is the code I have on the property data\data\search of the view:
var qstring;
if (sessionScope.searchNumfac != null & sessionScope.searchNumfac != "") {
qstring = "(Field numfac = *" + sessionScope.searchNumfac + "*)"
+ " OR (Field nomsociedad = *" + sessionScope.searchNumfac + "*)"
+ " OR (Field $14 = *" + sessionScope.searchNumfac + "*)";
}
sessionScope.queryString = qstring;
return qstring
Where searchNumFac corresponds to the value on the search box. The search on columns "numfac" and "nomsociedad" works great, but it fails on the $14 column. I also tried changing the $14 on the code by the column title on the Notes view (proveedor) and the column title on the XPage view (Proveedor), but it is still not working.
Do you know of any way to work around this?
Thanks a lot,
Carlos
View columns are not part of full text index. You have to use field names for your full text search.
In your example it means that instead of $14 you have to use the fieldnames from your column formula #If(nomprov="";cifprov;nomprov)):
...
+ " OR (Field nomprov = *" + sessionScope.searchNumfac + "*)"
+ " OR (Field cifprov = *" + sessionScope.searchNumfac + "*)";
Related
I feel I am missing something simple... The cheese example of how to use the rowFormatter is exactly how I want to implement something, except I'd like to add various additional columns...
I've noted the warning it is important to include only one column in your column definition array to ensure the table renders correctly, however it is exactly what I want to do.
So I tried adding another column to the table constructor which added a column heading but no data.
What an I missing? Surely this is a common use case?
Use the formatter option as apposed to the rowFormatter - which overwrites the entire rows contents.
Based on the printIcon and cheese examples in the Tabulator docs, construct a column formatter, but pass the row as apposed to the cell.
Then its just a matter of constructing the html table as per the cheese example, but return the table, don't append to the element.
My Test Example:
//Generate details
var details = function(row, formatterParams){ //plain text value
var element = row.getElement(),
data = row.getData(),
width = element.outerWidth(),
table;
//define a table layout structure and set width of row
table = $("<table style='width:" + (width - 18) + "px;'><tr></tr></table>");
//add image on left of row
$("tr", table).append("<td><img src='./img/teams/small-60x80/55015.png'></td>");
//add row data on right hand side
$("tr", table).append("<td><div><strong>Type:</strong> " + data.type + "</div><div><strong>Age:</strong> " + data.age + "</div><div><strong>Rind:</strong> " + data.rind + "</div><div><strong>Colour:</strong> " + data.color + "</div></td>");
//append newly formatted contents to the row
//element.append(table);
return table;
//return "<image src='./img/teams/small-60x80/55015.png'>";
};
//define Tabulator
$("#example-table").tabulator({
height:"600px",
layout:"fitColumns",
resizableColumns:false,
columns:[
{formatter:details},
{title:"Cheese", field:"type", sorter:"string"},
{title:"Something Else", field:"blah", sorter:"string"},
],
})
I have created an xPages custom control based on Dynamic View Panel. I then added 2 comboboxes filled with various values (States, Departments) and an editbox field and a Search button. I then coded the follow to return the search string onto a computed "Search in view results" for the panel.
var tmpArray = new Array("");
var cTerms = 0;
if(viewScope.categoryText1 != null) {
if ( viewScope.categoryText1.trim() != "") {
tmpArray[cTerms++] = "(FIELD State CONTAINS \"" + viewScope.categoryText1 + "\")";
}
}
if(viewScope.categoryText2 != null ){
if ( viewScope.categoryText2.trim() != "") {
tmpArray[cTerms++] = "(FIELD Department = \"" + viewScope.categoryText2 + "\")";
}
}
if(viewScope.searchString != null ) {
if ( viewScope.searchString != "") {
tmpArray[cTerms++] = "( \"" + viewScope.searchString + "\")";
}
}
qstring = tmpArray.join(" AND ").trim();
viewScope.queryString = qstring; // this just displays the query
return qstring // this is what sets the search property
The search works for the editbox field values but not for the strings generated by the comboboxes: 'FIELD State CONTAINS "some state"' or 'FIELD Department = "some deptname"'. These search strings return an empty view.
The Column names match the underlying Notesview (both programmatically and column title).
I think this might have something to do with what are the column names surfaced by the Dynamic View Panel but I'm not sure.
Full text search looks in document fields for search strings, not in column values.
So, make sure fields State and Department contain the strings you are looking for.
Do you use aliases? Maybe you save abbreviation for State in document only but user can select State's full name for search...
OK, I have a customer name and address and simply want to display this in one computed field instead of separate lines in a table to save real estate. I've tried several iterations of #newline but to no avail. Can someone give me some guidance?
I would also like to NOT include Address2 if it's blank. I'm new to javascript. Thanks for your help.
var a = document1.getItemValueString("CompanyName");
var b = document1.getItemValueString("Address1");
var c = document1.getItemValueString("Address2");
var d = #Char(13);
a + #NewLine() + b + "<br>" + c;
Set property escape="false" in computed field and add <br /> whenever you want a newline.
You can set this property in properties tab selecting content type "HTML" too:
Your code would be
var a = document1.getItemValueString("CompanyName");
var b = document1.getItemValueString("Address1");
var c = document1.getItemValueString("Address2");
a + "<br />" + b + (c ? "<br />" + c : "");
Mike,
I had to do nearly the same thing recently and used a Multiline Edit Box. Place your same code in data section of an <xp:inputTextArea> (Multiline Edit Box in palette) and then make it read-only.
I have a view in which I search for products. I'm for example looking for product 1234.
The problem is their also exist products called 1234A and 1234 C etc. When I look with the code mentioned below I get all the items from product 1234 but also from 1234A and 1234 C etc.
It has to be limited to items from product 1234 only
Search code (under Data / Search in view results):
var tmpArray = new Array("");
var cTerms = 0;
if (sessionScope.SelectedProduct != null & sessionScope.SelectedProduct != "") {
tmpArray[cTerms++] = "(FIELD spareProduct = \"" + sessionScope.SelectedProduct +
"\")";
}
if (sessionScope.Development != null & sessionScope.Development != "") {
tmpArray[cTerms++] = "(FIELD spareStatus = \"*" + sessionScope.Development +
"*\")";
}
qstring = tmpArray.join(" AND ").trim();
return qstring
I used the suggestion from Frantisek :
I made a view with a combined column . (combined with the different "keys" I search for)
Then instead of using data / search , I used data/keys with exact keymatch. In this key I combined the searched items.
Since I had a field in wich I had sometimes at the end a character "°" , and it seems that this character doesn't work with a lookup , I took it out of my view and searched item with #Word(FIELDNAME; "°" ; 1).
As Frantisek suggested I could have used #ReplaceSubstring( field; "°"; "" ) also.
I'm trying to find an effective method of filtering Sharepoint lists based on the age of an item. In other words, if I want to find list items that are 7 days old, I should be able to build a filtered view on the data.
There is a hack to build a "Today" field that works, but doesn't filter properly.
Does anyone have any good ideas?
If you want to filter only items that are less than 7 days old then you just use
Filter
Created
is greater than or equal to
[Today]-7
Note - the screenshot is incorrect.
[Today] is fully supported in view filters in 2007 and onwards (just keep the spaces out!) and you only need to muck around with calculated columns in 2003.
Have you tried this: create a Computed column, called 'Expiry', with a formula that amounts to '[Created] + 7 days'. Then use the computed column in your View's filter. Let us know whether this worked or what problems this poses!
In the View, modify the current view or create a new view and make a filter change, select the radio button "Show items only when the following is true", in the below columns type "Created" and in the next dropdown select "is less than" and fill the next column [Today]-7.
The keyword [Today] denotes the current day for the calculation and this view will show as per your requirement
Warning about using TODAY (or any calcs in a column).
If you set up a filter and have JUST [Today] it it you should be fine.
But the moment you do something like [Today]-1 ... the view will no longer show up when trying to pick it for alerts.
Another microsoft wonder.
Pass Today as value as mentioned below in $viewQuery property :
$web = Get-SPWeb "http://sitename"
$list = $web.Lists.TryGetList($listtitle)
write-host "Exporting '$($list.Title)' data from '$($web.Title)' site.."
$viewTitle = "Program Events" #Title property
#Add the column names from the ViewField property to a string collection
$viewFields = New-Object System.Collections.Specialized.StringCollection
$viewFields.Add("Event Date") > $null
$viewFields.Add("Title") > $null
#Query property
$viewQuery = "<Where><Geq><FieldRef Name='EventDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'><Today/></Value></Geq></Where><OrderBy><FieldRef Name='EventDate' Ascending='True' /></OrderBy>"
#RowLimit property
$viewRowLimit = 30
#Paged property
$viewPaged = $true
#DefaultView property
$viewDefaultView = $false
#Create the view in the destination list
$newview = $list.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView)
Write-Host ("View '" + $newview.Title + "' created in list '" + $list.Title + "' on site " + $web.Url)
$web.Dispose()