DevExpress Xtrareport Hide report header when detail section is empty - vb.net

I have a report with Detail Band bound to datasource.
in some cases, my report has multiple pages and the last page may contain Detail Band rows and other cases the last page has no Detail Band rows, so it will just show the page header with my report footer.
I want to hide the header when the last page has no detail rows.
I tried using PageHeader_BeforePrint Event, but I couldn't get any value to indicate whether the Detail section of this page is empty or not.
I used a row count label, but this counter in PageHeader_BeforePrint event always has the same value, although after printing finishes, the visible value of this counter is correct on every page.
so, the basic issue is: in PageHeader_BeforePrint How to determine whether the Detail Band section has rows or not?

Unfortunately there is no simple way to do that.
The similar solution was described on the dx-support page
you should manually count the rows and check it to cancel printing:
private int rowCounter = 0;
Detail.AfterPrint += (o, args) => { rowCounter++; };
PageHeader.BeforePrint += (o, args) =>
{
if (rowCounter >= this.RowCount)
args.Cancel = true;
};

Related

Selenium - How to Wait?

I need to be able to wait for one of multiple things that could happen to a page after a certain action is taken. Examples of these things are: URL changes, a certain title is set, certain content on the page appears, etc.
This explains how to wait - https://github.com/facebook/php-webdriver/wiki/HowTo-Wait. However, I need to be able to wait for multiple things at the same time. I want the waiting to stop once one of the conditions occur.
Is there a way to "or" during a wait (e.g. wait for URL to change OR title contains "foo" OR "bar" appears on the page, etc.)?
In the same link you posted, look for the "Custom conditions" section, i.e.:
$driver->wait()->until(
function () use ($driver) {
$elements = $driver->findElements(WebDriverBy::cssSelector('li.foo'));
return count($elements) > 5;
},
'Error locating more than five elements'
);
Note the use of findElements in the code example. When nothing is found, an empty array will be returned. If only one of three elements must be visible, you do something like:
$driver->wait()->until(
function () use ($driver) {
$elements1 = $driver->findElements(WebDriverBy::cssSelector('li.foo1'));
$elements2 = $driver->findElements(WebDriverBy::cssSelector('li.foo2'));
$elements3 = $driver->findElements(WebDriverBy::cssSelector('li.foo3'));
return count($elements1) + count($elements2) + count($elements3) > 0;
},
'Error locating at least one of the elements'
);

virtual ClistCtrl with checkboxes on displayed report list style

I have an MFC SDI application to display a list of data read from a csv file. So I set up its view to be inherited from CListView and make it a virtual list control. That means I have to use LVS_OWNERDATA as one of its CListCtrl style attributes. Yet I now run into a problem when I have to include Checkboxes in each row of the displayed list. As you might know, LVS_EX_CHECKBOXES can't be used with LVS_OWNERDATA, I therefore create a bitmap file to contain 2 small images of checkbox (selected and de-selected) and toggle them every time the user clicks on the loaded image/icon. I am handling this in OnNMClick method. And I have two problems I would like to ask for your help to solve.
(1) I don't know how to update the virtual list (which is commonly handled in OnLvnGetdispinfo method) so I try this in OnNMClick and find that the check and unchecked images aren't toggled.
void CMFCSDITest::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: Add your control notification handler code here
*pResult = 0;
LVHITTESTINFO hitinfo;
hitinfo.pt = pNMItemActivate->ptAction;
int nItem = pListCtrl->HitTest(&hitinfo);
if (hitinfo.flags != LVHT_ONITEMICON)
return;
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
LV_ITEM* pItem = &(pDispInfo)->item;
if (pItem->iImage == 0)
pItem->iImage = 1;
else
pItem->iImage = 0;
pListCtrl->SetItem(pItem);
pListCtrl->UpdateWindow(); //this is wrong as nothing seems updated after all.
}
Given that the created imagelist is inserted into the pListCtrl already (in OnInitialUpdate method) and I set the output image index value in OnLvnGetdispinfo method.
(2) Instead of handling OnNMClick, I read somewhere people's advice that OnLvnItemchanged method could also be used. However in LPNMLISTVIEW struct, there is uNewState and uOldState variable members for which I don't know how to set up my tiny checked and unchecked icons as status images. Because I might have to do this
if (pNMLV->uChanged & LVIF_STATE)
{
switch (pNMLV->uNewState & LVIS_STATEIMAGEMASK)
{
case image1://do
case image2://do
}
}

Datatables: Showing a summary row for sub rows

I'm new to Datatables...
I'm making a grid of rows, each with sub (details) rows. I'm using server-side data from a mysql database. It is returned as JSON containing all sub rows.
I need to create the "main" grid rows, summing up columns from the sub rows. I'm not sure if Datatables can do this or how it is done...
I'm thinking about starting by getting the JSON in a JQuery function. Then using a loop to sum up data I need and pass that on to the grid as array-data. Lastly I render the grid.
Is this best practice or is Datatables capable of doing it in a smarter way?
-- the concept of sub rows can be seen here: http://datatables.net/blog/Drill-down_rows --
I have completed something like this. I returned all the data I needed and put the "details" information into the last column in a hidden div. Then used a row click to put that information into the details row.
//In the example the table the first column has a plus icon that gets replace with a minus icon
// the last column added a hidden div that contained the details.
$("#results").dataTable({
"fnCreatedRow": function (nRow, aData, iDataIndex) {
//Attach the on click event to the row
var oTable = this;
$("td:eq(0) span", nRow).on("click", function () {
//First column has a image with the jQuery UI plus icon
if ($(this).hasClass("ui-icon-circle-plus")) {
//The details information is stored in the last column in a hidden div with the class wrapper
//Grab the hidden information and append that to the new row.
oTable.fnOpen(nRow, $(".wraper", nRow).html(), "details");
} else {
oTable.fnClose(nRow);
}
$(this).toggleClass("ui-icon-circle-plus ui-icon-circle-minus");
});
}
});

RichTextBlock overflow, keep paragraphs together on one page (in one overflow control)

I am printing RichTextBlock contents, using RichTextOverflow for pagination, it's working great but I would like to keep paragraphs together on one page, and now sometimes I have page breaks in middle of paragraph.
Here is the example :
Paragraph 3 should be on the next page, it seems that ITextParagraphFormat.KeepTogether is just what I need but don't know how to get that for RichTextBlock.
If you put your paragraph inside TextBlock/RTB inside InlineUIContainer it will be treated as a single element and will carry over to the next page unbroken if needed. This approach may have some side effects, but I believe it should work for printing.
After all I made a method that will "push" paragraphs that are broken on two pages on to a next page, I am not very happy about this solution but I didn't found another way
public static void BreakBeforeLastParagraph(RichTextBlockOverflow rto)
{
if (!rto.HasOverflowContent)
return;
var pageBreak = rto.ContentEnd.Offset;
var brokenPar = rto.ContentSource.Blocks.FirstOrDefault(pr => pr.ElementStart.Offset <= pageBreak && pr.ElementEnd.Offset >= pageBreak);
if (brokenPar != null)
{
double spacerSize = pageBreak - brokenPar.ElementStart.Offset;
var spacer = new Paragraph();
spacer.Margin = new Windows.UI.Xaml.Thickness(0,spacerSize, 0,0);
rto.ContentSource.Blocks.Insert(rto.ContentSource.Blocks.IndexOf(brokenPar), spacer);
}
rto.UpdateLayout();
}

Dojo EnhancedGrid and programmatic selection

Here's my problem: in my application I have a Dojo EnhancedGrid, backed up by an ItemFileReadStore. The page flow looks like this:
The user selects a value from a selection list.
The item from the list is posted on a server and then the grid is updated with data from the server (don't ask why, this is how it's supposed to work)
The new item is highlighted in the grid.
Now, the first two steps work like a charm; however, the third step gave me some headaches. After the data is successfully POSTed to the server (via dojo.xhrPost() ) the following code runs:
myGrid.store.close();
myGrid._refresh();
myGrid.store.fetch({
onComplete : function(items) {
for ( var i = 0; i < items.length; i++) {
if (items[i].documentType[0].id == documentTypeId) {
var newItemIndex = myGrid.getItemIndex(items[i]);
exportMappingGrid.selection.deselectAll();
exportMappingGrid.selection.addToSelection(newItemIndex);
}
}
}
});
Now, the selection of the grid is updated (i.e. the selection object has a selectedIndex > 0), but visually there's no response, unless I hover the mouse over the "selected" row. If I remove the .deselectAll() line (which I suspected as the culprit) then I sometimes end up with two items selected at once, although the grid selectionMode attribute is set to single.
Any thoughts on this one?
Thanks a lot.
You need to use setSelected(), like so
exportMappingGrid.selection.setSelected(newItemIndex, true);
The second parameter is true to select the row, false to unselect it.
This is what works for me:
grid.selection.clear();
grid.selection.addToSelection(newItemIndex);
grid.selection.getFirstSelected();
Jon