I am trying to merge two notesdocumentcollections together using the following code in a repeat control (Domino 8.5.3):
var tempDC:NotesDocumentCollection = resourceDB.getProfileDocCollection("temp");
if (otherImgDC.getCount() > 0) {
tempDC.merge(otherImgDC);
print(otherImgDC.getCount() + ", " + tempDC.getCount());
}
if (techDiagramDC.getCount() > 0) {
tempDC.merge(techDiagramDC);
}
return tempDC;
But the print statement returns 0 for tempDC.getCount() - what am I missing here? Any help would be appreciated.
Fixed the problem. although would still like to know why merge doesn't work with empty collection:
if (otherImgDC.getCount() > 0) {
if (techDiagramDC.getCount() > 0) {
otherImgDC.merge(techDiagramDC);
}
return otherImgDC;
} else {
if (techDiagramDC.getCount() > 0) {
return techDiagramDC;
}
}
Did you check the collections before the merge? All 3 of them?
And for the fun of it: move them to a Java class you call from the SSJS.
Related
I am using the code by Rick Sibley from the first answer on this post: Search within an accordion
Rick mentions that a search button can be added to run the script onclick, in addition to pressing enter to submit and run the search script. Can any body help me add the search 'button' functionality to this, please?
Thanks so much!
I figured it out! I feel like a genius - though I am obviously very bad at this.
Here's what I added in addition to the keyup event listener:
//Search Accordings; Highlight & Open Matching Areas ON SEARCH BUTTON CLICK
function searchBtn() {
var input, filter, i, acc, panels, txtValue, searchText, searchTitle;
input = document.getElementById("keywordSearch");
filter = input.value.toUpperCase();
acc = document.getElementsByClassName("accordion");
panels = document.getElementsByClassName("panel");
for (i = 0; i < panels.length; i++) {
for (i = 0; i < acc.length; i++) {
searchText = panels[i].textContent || panels[i].innerText;
searchTitle = acc[i].textContent || acc[i].innerText;
if (input.value !== "") {
if (searchText.toUpperCase().indexOf(filter) > -1 || searchTitle.toUpperCase().indexOf(filter) > -1) {
if (!acc[i].classList.contains("active")) {
acc[i].classList.add("active");
}
highlightIndex.apply(filter);
panels[i].style.maxHeight = panels[i].scrollHeight + "px";
panels[i].scrollIntoView({
behavior: 'smooth'
});
} else {
if (acc[i].classList.contains("active")) {
acc[i].classList.remove("active");
}
panels[i].style.maxHeight = null;
}
} else {
highlightIndex.remove();
if (acc[i].classList.contains("active")) {
acc[i].classList.remove("active");
}
panels[i].style.maxHeight = null;
}
}
}
}
With the following button added in html
<button type="submit" id="searchBtn" onclick="searchBtn();">Search</button>
I am new to node.js / protractor and want to select select all checkboxes in a dropdown. My code works but there is a problem with 2 of the items that have the same text. When selected, both are checked. In my code I want to skip these 2 items but my text comparison isn't working.
Since selecting one of these duplicate items checks both, selecting the second one un-selects both. For simplicity I'd prefer to merely skip these when they are found in the forEach loop.
element.all(by.xpath('//*[#id="work-bench"]/div[1]/div[1]/div/div[5]/div/div[3]/ul')).all(by.className('checkbox')).then(function(totalDCs) {
console.log('DCs in Dropdown List ' + (totalDCs.length));
DCCount = totalDCs.length;
});
element.all(by.className('multiselect__element')).then(function(options) {
var i = 0;
var j = 1;
options.forEach(function(option) {
option.getText().then(function(text) {
console.log(text + ' was selected');
i++;
if(text != 'FULFILLMENT') {
option.click();
if(DCCount-j == i) {
return DCCount;
}
}
else {
j++;
console.log('j equals ' + j);
}
});
});
});
The line if(text != 'FULFILLMENT') doesn't recognize the match and thus performs the selection (twice).
Try to use
if(text !== 'FULFILLMENT')
or
if(!text.localeCompare('FULFILLMENT'))
and tell us if that works for you
In a UWP app, I am using a RichTextBlock that gets populated with some content. It has word wrapping enabled and has a max lines set so that regardless of the length of its content, it will only show a certain number of lines of rich text.
I'd like to know if there is a way to figure out what is the visible text?
So if I have:
<RichTextBlock TextWrapping="Wrap" MaxLines="2">
<RichTextBlock.Blocks>
<Paragraph>
<Paragraph.Inlines>
A bunch of runs go in here with text that are several lines
</Paragraph.Inlines>
</Paragraph>
</RichTextBlock.Blocks>
</RichTextBlock>
I'd like to know how much of the text is actually visible.
I'm trying to detect cases where the text is longer than a set number of lines and append a "... Read More" at the end of the last line (replacing the last 13 chars with "... Read More")
So I wrote some code to get the behavior that I want, but unfortunately this is rather slow and inefficient. So if you're using it in an app that is primarily to show a lot of text that needs to be truncated (like a ListView with a lot of text items) then this would slow down your app perf. I still would like to know if there is a better way to do this.
Here's my code (which only handles Run and Hyperlink inlines so you'll have to modify to handle other types that you need):
private static void TrimText_Slow(RichTextBlock rtb)
{
var paragraph = rtb?.Blocks?.FirstOrDefault() as Paragraph;
if (paragraph == null) { return; }
// Ensure RichTextBlock has passed a measure step so that its HasOverflowContent is updated.
rtb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
if (rtb.HasOverflowContent == false) { return; }
// Start from end and remove all inlines that are not visible
Inline lastInline = null;
var idx = paragraph.Inlines.Count - 1;
while (idx >= 0 && rtb.HasOverflowContent)
{
lastInline = paragraph.Inlines[idx];
paragraph.Inlines.Remove(lastInline);
idx--;
// Ensure RichTextBlock has passed a measure step now with an inline removed, so that its HasOverflowContent is updated.
rtb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
}
// The last inline could be partially visible. The easiest thing to do here is to always
// add back the last inline and then remove characters from it until everything is in view.
if (lastInline != null)
{
paragraph.Inlines.Add(lastInline);
}
// Make room to insert "... Read More"
DeleteCharactersFromEnd(paragraph.Inlines, 13);
// Insert "... Continue Reading"
paragraph.Inlines.Add(new Run { Text = "... " });
paragraph.Inlines.Add(new Run { Text = "Read More", Foreground = new SolidColorBrush(Colors.Blue) });
// Ensure RichTextBlock has passed a measure step now with the new inlines added, so that its HasOverflowContent is updated.
rtb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
// Keep deleting chars until "... Continue Reading" comes into view
idx = paragraph.Inlines.Count - 3; // skip the last 2 inlines since they are "..." and "Read More"
while (idx >= 0 && rtb.HasOverflowContent)
{
Run run;
if (paragraph.Inlines[idx] is Hyperlink)
{
run = ((Hyperlink)paragraph.Inlines[idx]).Inlines.FirstOrDefault() as Run;
}
else
{
run = paragraph.Inlines[idx] as Run;
}
if (string.IsNullOrEmpty(run?.Text))
{
paragraph.Inlines.Remove(run);
idx--;
}
else
{
run.Text = run.Text.Substring(0, run.Text.Length - 1);
}
// Ensure RichTextBlock has passed a measure step now with the new inline content updated, so that its HasOverflowContent is updated.
rtb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
}
}
private static void DeleteCharactersFromEnd(InlineCollection inlines, int numCharsToDelete)
{
if (inlines == null || inlines.Count < 1 || numCharsToDelete < 1) { return; }
var idx = inlines.Count - 1;
while (numCharsToDelete > 0)
{
Run run;
if (inlines[idx] is Hyperlink)
{
run = ((Hyperlink)inlines[idx]).Inlines.FirstOrDefault() as Run;
}
else
{
run = inlines[idx] as Run;
}
if (run == null)
{
inlines.Remove(inlines[idx]);
idx--;
}
else
{
var textLength = run.Text.Length;
if (textLength <= numCharsToDelete)
{
numCharsToDelete -= textLength;
inlines.Remove(inlines[idx]);
idx--;
}
else
{
run.Text = run.Text.Substring(0, textLength - numCharsToDelete);
numCharsToDelete = 0;
}
}
}
}
I'm new in WPF trying to use ReactiveUI,
I want to call 3 different method based on property value changed.
so
public int Number
{
set
{
number = val;
if (_number == 1) Call1()
else if (_number == 2) call2()
else if (_number == 3) call3()
}
}
above is working but now I'm trying using ReactiveUI
so what i did
this.ObservableForProperty(x => x._number).Subscribe( => Call1());
is there any way to achieve above?
If you set up your property like this (assuming your class derives from ReactiveObject):
public int Number
{
get
{
return _number;
}
set
{
this.RaiseAndSetIfChanged(ref _number, value);
}
}
Or, you need to get it to fire property changed notifications some other way.
You didn't say if you are observing the property within the class itself or from a different one. For example, is this all occurring in your ViewModel or in your View watching your ViewModel?
If within the ViewModel with the Number property, I would try something along these lines:
this.WhenAnyValue(t => t.Number)
.Subscribe(i =>
{
if (i == 1)
{
Call1();
}
else if (i == 2)
{
Call2();
}
else if (i == 3)
{
Call3();
}
}
);
If you were in your View that had a ViewModel property holding the ViewModel with the Number property I would try:
this.ObservableForProperty(t => t.ViewModel.Number,i => i)
.Subscribe(i =>
{
if (i == 1)
{
Call1();
}
else if (i == 2)
{
Call2();
}
else if (i == 3)
{
Call3();
}
}
);
How about this:
this.WhenAnyValue(x => x.Number)
.Where(x => x == 1)
.Subscribe(Call1);
I have tried:
while (System::Runtime::InteropServices::Marshal::ReleaseComObject(worksheet_instance) > 0) ;
workbook_instance->Close(true, "Dummy.xlsx", Missing::Value);
while (System::Runtime::InteropServices::Marshal::ReleaseComObject(workbook_instance) > 0) ;
workbook_instance->~Workbook();
exApp_instance->Quit();
exApp_instance->~Application();
But it does not terminate the excel application (I still see it in the task manager).
As a try, I would like to do something like
workbook_instance = NULL;
but it is not accepted.
Any suggestion?
Thank you.
Thank you #amaldev
According to some ideas collected from the first link, I succeeded with
try{
while (System::Runtime::InteropServices::Marshal::ReleaseComObject(ws) > 0) ;
} catch(...) {}
wb->Close(false, Missing::Value, Missing::Value);
try {
while (System::Runtime::InteropServices::Marshal::ReleaseComObject(wb) > 0) ;
} catch(...) {}
exApp->Quit();
try {
while (System::Runtime::InteropServices::Marshal::ReleaseComObject(exApp) > 0) ;
}
catch(...) {}
System::GC::Collect();
System::GC::WaitForPendingFinalizers();