Lotus Designer - #Trim undone when using sorting - lotus-notes

My application have a table that have 3 columns to be used in View:
In View, all 10 rows will share a column using show multiple values as separate entries and #Trim.
I want to sort Expired By column in ascending order, but when I did that and refresh my view, it seem to have undone the #trim
Is #Trim not compatible with sort functions?

Change your "Expired On" column formula to
#ToTime(#Trim(
#If(cert != ""; #Text(certend); "") :
#If(cert_1 != ""; #Text(certend_1); "") :
#If(cert_2 != ""; #Text(certend_2); "") :
#If(cert_3 != ""; #Text(certend_3); "") :
#If(cert_4 != ""; #Text(certend_4); "") :
#If(cert_5 != ""; #Text(certend_5); "") :
#If(cert_6 != ""; #Text(certend_6); "") :
#If(cert_7 != ""; #Text(certend_7); "") :
#If(cert_8 != ""; #Text(certend_8); "") :
#If(cert_9 != ""; #Text(certend_9); "")))
It adds certend values only if related cert values are not empty. As you want to sort by this column too you have to use it as DateTime and not as Text type.
Change order of columns. Only the first of the multivalue columns can be sorted. The following multivalue columns have to be unsorted (sort: "none").

Related

Tabulator - problem with custom header filters and searchData()

I am using searchData() to count rows under different conditions for display to the user, without affecting the table itself. Specifically one col is "available" and I want to show how many rows there are depending on the filter criteria set, for both available and unavailable states. Most filters are normal default type header filters.
To do this I use the dataFiltered() callback. Inside the callback I get all the filters in a list, then do a count with and without an "available" filter added to the list. The problem is that I have one column with a custom header filter, and Tabulator complains if this one is active when searchData() is called. The custom filter works as expected in the table. Relevant code snippets are:
//table def
dataFiltered:function(filters, rows) { SetCounts(filters, rows) },
// col def
{title:"Sex", field:"sex", visible:true, hozAlign:"center", headerSort:false,
headerFilter:true, headerFilterFunc:customSexFilter,
},
// custom filter
function customSexFilter(headerValue, rowValue, rowData, filterParams) {
return (headerValue == rowValue) || (headerValue == "M" && rowValue == "N") || (headerValue == "F" && rowValue == "S");
}
// dataFiltered callback (simplified; one of two cases shown)
var availFilter = { field: "avail", type: "like", value: "A"};
function SetCounts(filters, rows) {
if (!table) return;
var filt = table.getHeaderFilters().concat(filters.slice());
var nAll = rows.length;
var fA = filt.slice();
fA.push( availFilter );
var nAvail = table.searchData(fA).length;
\$("#rowCount").html([nAll, '/', nAvail, 'A'].join(''));
}
The error that I get is Filter Error - No such filter type found, ignoring: function o(o)
and the filter itself shows as
field: "sex"
type:o(o)
value: "F"
I've studied the docs but can't figure out what I'm doing wrong. Or is this not supported? Version 4.6.

Xpages: Keep view sort order when filtering on view

My Xpage has a dataView that points to a view which is sorted by employee name. One of the other fields in the employee view is their Location. I have a combobox in the header of the view that allows a user to subset to one location. When subsetted the correct employees appear, but the sort order is lost.
I have looked at a few answers in Stack overflow such as this and this. but cannot get them to work. I think the difference is that
I am not trying to filter on a value that is sorted.
Here is my code for the FT Search:
var tmpArray = new Array("");
var cTerms = 0;
//Geo Location Search
if(viewScope.key != null & viewScope.key != "" & viewScope.key != "All Locations" & viewScope.key != "--Select a Location--") {
tmpArray[cTerms++] = "(FIELD HR_GeoLocation = " + viewScope.key + ")";}
qstring = tmpArray.join(" AND ").trim();
viewScope.queryString = qstring; // this just displays the query
return qstring // this is what sets the search property
The view's first field is the users last name, first name, descending.
FTSearch doesn't return found documents in view's order:
The collection of documents that match the full-text query are sorted
by relevance, with highest relevance first.
Use an additional view which is categorized by Location and use Location as key in
Filter by category name (categoryFilter) or
Filter by column value
(keys/keysExactMatch)
The columns after Location-column are the same as in your current view.

Maximum value in datatable column c#

I have a set of text files that I am reading into a datatable. I want to be able to read the frist column (Id) and find out the highest number. Each of the files goes from 0 to at least 21 sequentially. I tried suggestions from the following link: How to select min and max values of a column in a datatable?
Sadly, I could not any to work. The one suggestion that kind of worked is shown in the second last line, but it returns a value of 8 or 9. Any suggestions as to how to properly get the results I am looking for?
string filePath = System.IO.Path.GetFullPath(curriculum);
DataTable curriculmDataTable = new DataTable();
curriculmDataTable.Columns.Add("Id");
curriculmDataTable.Columns.Add("Course");
curriculmDataTable.Columns.Add("Credit");
// Read in a file line-by-line, and store it
var txtFileLine = File.ReadAllLines(filePath).ToList();
//Reads line splits data to colums at tab (ASCII value 9)
txtFileLine.ForEach(line => curriculmDataTable.Rows.Add(line.Split((char)9)));
//Suggestions from link
int max = Convert.ToInt32(curriculmDataTable.Select("Id=max(Id)")[0][0]);
label1.Text = ""+ max;
The problem is that you have created string columns but you want to get the max-values according to their numeric value. The best way is to store the corrrect type in the first place. Then you could either use DataTable.Compute or Linq-To-DataSet:
create an int column:
curriculmDataTable.Columns.Add("Id", typeof(int));
convert the strings to int and add them to the table:
foreach(string line in File.ReadLines(filePath))
{
DataRow row = curriculmDataTable.Rows.Add();
string[] fields = line.Split(new[]{(char)9});
int id;
if(fields.Length == 3 && int.TryParse(fields[0], out id)
{
row.SetField("Id", id);
row.SetField("Course", fields[1]);
row.SetField("Credit", fields[2]);
}
}
Now you can use Linq:
int maxID = curriculmDataTable.AsEnumerable().Max(r => r.Field<int>("Id"));
DataTable.Compute (works also with earlier .NET versions):
int maxID = (int)curriculmDataTable.Compute("Max(Id)", "")
We can get max value from the column in a dataTable using this syntax
var maxValue = dataTblDetails.Compute("max(ColumnName)", string.Empty);

Programmatically access external list associated column

Hi I have 2 external lists 'A' and 'B'. with an associated column in A, that looks up for B.
When i view/edit item in browser, it shows correct values as shown in picture below.
But when i try to access the list in code, i can access all column values, but associated column value comes null.
The code look something like this :
items = listReports.GetItems();
System.Collections.Generic.List<ReportItem> reportItems = new List<ReportItem>();
foreach (SPListItem it in items)
{
if (it != null)
{
ReportItem item = new ReportItem();
// extItem comes null
var extItem = it["ExtCol"];
// extItem comes null
DateTime date;
if (DateTime.TryParse(it["GeneratedOn"].ToString(), out date))
{
item.dateGenerated = date.Date;
}
DateTime time;
if (DateTime.TryParse(it["GeneratedOn"].ToString(), out time))
{
item.timeGenerated = time.Date;
}
reportItems.Add(item);
}
}
I'm not sure, but, "ExtCol" - is that rigth name for field in your external type? For external items sharepoint may substitute a name of external item/column in the source field name.

j2me+choice group

I am working on the project where i had used choice group in form. Now I want to get the selected item or index number of the choice group and want to perform some action.
I had tried through this:-
System.out.println(cgPrefs.getString(i) + (selected[i] ? ": selected" : ": not selected"));
But I am not getting the exact index number of the selected item in choice group.
You will get flags according to selection
boolean[] selectedFlag = new boolean[getChoiceGroup().size()];
using getSelectedFlags() method
getChoiceGroup().getSelectedFlags(selectedFlag);//getChoiceGroup() returns object of choicegroup
Now iterate and print
for(int i = 0 ; i < selectedFlag.length; i ++){
if(selectedFlag[i]){
System.out.println("Selected : "+getChoiceGroup().getString(i));
}else{
System.out.println("Not Selected : "+getChoiceGroup().getString(i));
}
}

Resources