i have a report in .repx format. with a group header , detail and group footer.
The problem is when no more space for group footer on first page , the group footer is printed on next page , but on this page is printed the group header too , even if there's no more records in detail section . How can i do that if no more records in detail section the group header to be invisible on next page.
Thank you !
Refer this How do I hide the GroupFooterBand when the grouping field is empty or null?
There are two approaches to achieve this, but i suggest you to follow as below:
If you can find out which detail bands will be hidden in the
GroupHeaderBand.BeforePrint and GroupFooterBand.BeforePrint event
handlers, then you can hide corresponding group header and footer.
References:
Hide GroupHeader & GroupFooter
[source from the report.]
How to shrink groupHeader or to hide a xrtable in the groupHeader - don't work
suppress group footer if group header is suppressed
How to hide GroupFooterBand on the last page
GroupFooter BeforePrint with Hierarchical data structure
The solution I came up with for nearly an identical problem was to keep track of a counter that resets on each page.
First, wire up BeforePrint on the TopMargin band, which prints on every page:
private int detailsPrintedThisPage = 0;
private void TopMargin_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
detailsPrintedThisPage = 0;
}
Next, whenever a detail prints, keep track of that:
private void Details_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
detailsPrintedThisPage++;
}
Finally, on the group footer, if no details have printed this page, then suppress the footer:
private void GroupFooter1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
e.Cancel = (detailsPrintedThisPage == 0);
}
The problem I was solving was initially the same as yours, except that my group footer was nothing but a blank label meant to provide padding between groups. The blank spacing was causing an entire page to print (with a group header) on the last page if the details lined up just right to be wrong, which is exactly the case you describe.
In my case, however, I simplified the problem by removing the footer altogether and added extra space before the group header that I suppressed if it was the first group header printed on a given page. However the code above is adapted from my solution to where it should work in the more general case you describe where you want to hide the group footer specifically if there are no details on the page. Sharing 7 years late in case it helps someone else who lands here...
Related
I have a RadGrid that has a WebUserControl for each row of the grid to allow the user to edit that row. When I click the edit button to expand the row (this opens up a .ascx control within the grid for that row), it always scrolls to the top of the page. The user then has to scroll down to find the row they selected with the row expanded to begin editing that row.
I found in another post that adding RadGrid1.ClientSettings.AllowKeyboardNavigation = true; prior to data binding the grid helps to maintain scroll position. This kind of works and you only have to scroll down one click of the mouse wheel to find the row to edit; not good enough.
I also have set MaintainScrollPositionOnPostback=“true" on the aspx page.
I also have set on the RadGrid itself under client settings SaveScrollPosition=“true".
What I'd like to see is the page not move at all when the user clicks on edit for the given row. I would like to maintain the scroll position on the page.
Can this be accomplished? If so, how?
I finally figured out why my grid always scrolled to the top. It was my fault. I wanted the user to see any message from the WebUserControl when control pass back to the parent page. The RadGrid1.ClientSettings.Scrolling.ScrollTop = 0; was the issue.
I had the following code listed:
private void DisplayMessage()
{
// Display any messages from RadGrid2 that occurred in WebUserControl
if (!string.IsNullOrEmpty(Convert.ToString(Session["LabelUpdated"])))
{
lblUpdated.Text = Convert.ToString(Session["LabelUpdated"]);
Session["LabelUpdated"] = null;
}
RadGrid1.ClientSettings.Scrolling.ScrollTop = "0";
lblUpdated.Focus();
}
I've since changed it to what is below:
private void DisplayMessage()
{
// Display any messages from RadGrid2 that occurren in WebUserControl
if (!string.IsNullOrEmpty(Convert.ToString(Session["LabelUpdated"])))
{
lblUpdated.Text = Convert.ToString(Session["LabelUpdated"]);
Session["LabelUpdated"] = null;
RadGrid1.ClientSettings.Scrolling.ScrollTop = "0";
lblUpdated.Focus();
}
}
After the change the grid will only scroll to the top when a message is present from the WebUserControl.
(There already is a question regarding this but it has no answer and the comment isn't helpful either.)
I've got a TableView and I'd like to have a column with multiline labels that I can edit. Ideally, the behaviour would be like a TextFieldTableCell but with multiline support:
It displays text like a label.
When clicked, it transforms into a TextField (or in this case, a TextArea) so the text can be edited.
I haven't found a solution for this yet. The only workaround I've got right now is put a TextArea as the cell's "graphic":
descriptionTableColumn.setCellFactory(param -> new TableCell<Attachment, String>() {
#Override
protected void updateItem(String item, boolean empty) {
if (empty) {
setGraphic(null);
} else {
TextArea area = new TextArea(item);
area.setMinHeight(USE_COMPUTED_SIZE);
area.setPrefHeight(USE_COMPUTED_SIZE);
area.setMaxHeight(USE_COMPUTED_SIZE);
setGraphic(area);
}
}
});
(Code to listen to the text changes is missing here; it doesn't trigger the OnEditCommit event.)
However, the TextArea is always rendered as a normal TextArea with a border and white background. I can live with that. But the area also always renders with a certain height (about 180px) even when it's empty, even though I set USE_COMPUTED_SIZE.
So the question is:
Is there a way to get the ideal behaviour, similar to the TextFieldTableCell?
If not, is there a way to have the TextArea only use as much height as needed?
Ok, the basic idea is to copy the TextFieldTableColumn and adjust its behavior to create a TextAreaTableColumn. I hacked a small working example implementation together: https://gist.github.com/eckig/30abf0d7d51b7756c2e7
Usage:
TableColumn<?, ?> column = new TableColumn<>();
column.setCellValueFactory(...);
column.setCellFactory(TextAreaTableCell.forTableColumn()); // add StringConverter if neccessary
tableView.getColumns().add(column);
But, there are still some things left which need to be implemented / some tuning:
Adjust prefRowCount to show only the necessary amount of rows.
Maybe adjust prefColumnCount?
Because the "Enter" Key gets consumed for a new-line, I had to add a Save Button to commit the edit. This is somewhat ugly, but for now I do not have a better idea.
But hopefully you get the idea ;-)
I'm trying to scroll down to the bottom of a grid, after the model was setted.
1) I set the model:
myGrid.setModel(new ListModelList<Object>(myList));
2) I override the row renderer
myGrid.setRowRenderer(new RowRenderer<Object>() {
#Override
public synchronized void render(Row row,final Object data, int index) throws Exception {
row.setStyle("commonCellPadding");
.
.
.
row.appendChild(htmlMessage);
}
});
3) Finally if the list used to set the model is too big (the grid in the .zul has fixed height) i want to show the last results (the more recents in this case).
I need to scroll down automatically after the render. How can i do this?
Things i had try
a) Calling a javascript function after the render, this doesn't work due to the fact that the gridEle.scrollHeight attribute returns the fixed height of the grid setted in the zul (or 0 if not) and not the grid's height after the model was setted.
myGrid.addEventListener(ZulEvents.ON_AFTER_RENDER, new EventListener<Event>() {
public void onEvent(Event event) throws Exception
{
Clients.evalJavaScript("var gridEle = document.getElementById('"+myGrid.getUuid()+"-body"+"'); gridEle.scrollTop = gridEle.scrollHeight;alert(gridEle.scrollHeight);");
}
});
Why don't you sort the myList descending at first to make the last row become the first one instead to control the scroll bar?
In my opinion, it would be more easy and matching the users experience.
Just call Clients.scrollIntoView(rows.getLastChild()); after you have set the model and row renderer (provided rows is Rows component id and is already auto wired into your controller). See the live demo on zkfiddle here and source
UPDATE: Clients.scrollIntoView(Component) wouldn't work if you are using Render-On-Demand feature because naturally if the row that you want to scroll to wouldn't have been loaded on initial page load.
I am trying to print a multiple-page FlexPrintJob, that includes on the first page, several labels, then a PrintDataGrid. It all prints, except that the PrintDataGrid only prints using half the page on all the pages.
I know it has to do with the labels that I am printing on page 1, because taking them off or hiding them fixes the issue and the grid prints full page all pages.
I have tried various containers around the grid and labels, including VBox, VGroup, Group, and specifying different combinations of height="100%" for some of the containers.
Is it simply not possible to print a half page of variables / labels on page 1, then start the data grid on the same page (half page worth), but then have it go to full page on the following pages?
Here is my print job code:
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {
var thePrintView:printViewEventUser = new printViewEventUser(); // Create a FormPrintView control as a child of the application.
addElement(thePrintView);
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.parentEncounter=parentEncounter; //pass in my object for the labels to print
thePrintView._currentRec=_currentRec; //pass in my object for the labels to print
thePrintView.myDataGrid.dataProvider = bedSearchEditList._recs;
thePrintView.showPage("single"); // Create a single-page image.
if(!thePrintView.myDataGrid.validNextPage) // If the print image's DataGrid can hold all the data provider's rows, add the page to the print job.
{
printJob.addObject(thePrintView,FlexPrintJobScaleType.NONE);
}
else // Otherwise, the job requires multiple pages.
{
thePrintView.showPage("first"); // Create the first page and add it to the print job.
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
while(true) //queue pages
{
thePrintView.myDataGrid.nextPage(); // Move the next page of data to the top of the PrintDataGrid.
thePrintView.showPage("last"); // Try creating a last page.
if(!thePrintView.myDataGrid.validNextPage) // If the page holds the remaining data, or if the last page was completely filled by the last grid data, queue it for printing. Test if there is data for another PrintDataGrid page.
{
printJob.addObject(thePrintView,FlexPrintJobScaleType.MATCH_WIDTH); // This is the last page; queue it and exit the print loop.
break;
}
else // This is not the last page. Queue a middle page.
{
thePrintView.showPage("middle");
printJob.addObject(thePrintView,FlexPrintJobScaleType.MATCH_WIDTH);
thePrintView.pageNumber++;
}
}
}
removeElement(thePrintView);
}
printJob.send(); // Send the job to the printer.
My print view object is basically just an around my labels, then a PrintDataGrid.
If I remember correctly I fixed a similar situation in the past specifying a minHeight property to my mx:PrintDataGrid like this..
<mx:PrintDataGrid id="printViewDataGrid" width="100%" minHeight="500">
...
</mx:PrintDataGrid>
Good luck!
I have an Aspxgridview control and I enabled editing. So there is a column as "Edit". When I press it, it popups the row edit window --you all know that so far.
There are 2 columns has to be edited when I press the edit button. And I want to show a red image instead of edit button when this columns are not edited yet(I have an edited bool value in my database -0 default), after editing, I want this image to be changed with a green one. So I have the boolean column, I have 2 images and a command column with an editbutton. Possible to make that happen?
Thanks in advance.
Yes, it is possible to implement. First, you should set the CommandColumn.ButtonType to the Image value. To customize the button's image, use the ASPxGridView's CommandButtonInitialize event. Here is a sample code:
protected void ASPxGridView1_CommandButtonInitialize(object sender, ASPxGridViewCommandButtonEventArgs e) {
if(e.ButtonType == ColumnCommandButtonType.Edit) {
if(e.VisibleIndex % 2 == 0)
e.Image.Url = "Images/Copy.bmp";
else
e.Image.Url = "Images/Design.bmp";
}
}