I'm just trying to right align a cell in the exported PDF using the WebHierarchicalDataGrid and WebDocumentExporter - 13.1.20131.2107
Here's my column:
<ig:BoundDataField Key="Hours" DataFormatString="{0:###,##0.0}" Width="4%" DataType="System.Decimal" CssClass="numCol"> <Header Text="Hours" CssClass="right"></Header> </ig:BoundDataField>
The numCol class just sets the text-align to right. It works fine in the browser.
.numCol {text-align: right !important;white-space: nowrap; }
I even went so far as to try to set the report's cell alignment in all the events but they don't take.
void docExporter_GridRecordItemExported(object sender, DocumentGridRecordItemExportedEventArgs e) { string css = e.GridCell.Column.CssClass.ToLower(); if (css.Contains("numcol")) { e.CellElement.Alignment.Horizontal = Alignment.Right; } }
Any ideas? Thanks!
Hello,
I will be happy to assist you with your question.
After briefly looking over your code, I see that you are using the GridRecordItemExported event which fires after a GridRecordItem has finished exporting. If this is the case, setting the Alignment for the CellElement in this event would be to late. I recommend using the GridRecordItemExporting event for the WebDocumentExporter to get the behavior you are requesting.
To learn more about the GridRecordItemExporting event, please visit our online help documentation using the link below:http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=Infragistics4.Web.v13.1~Infragistics.Web.UI.GridControls.WebDocumentExporter~GridRecordItemExporting_EV.html
Please let me know if you have any questions regarding this matter.
I've tried all of the events and I can't get it to right align. I've tried applying the alignment to the cells too. I've attached a simple project. Can you try it out?
Hello Dirk,
Thanks for the update and sample.
I have indeed been able to reproduce the alignment behavior you've described. After further investigation, I was able to prevent this behavior after using an instance of the WebDocumentExporter added at DesignTime; I've added a modified sample you can use as reference to help demonstrate this.
To help resolve this issue, I have created case number CAS-124019-L1G2K0 for you. To access the case, simply log into your Infragistics account and click on My Support Activity. Also, I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 153696. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
Note, I will post the any solutions for this issue on this forum.
Upon further investigation of your code, we noticed the RunTime instance didn't work correctly because the WebDocumentExporter object was not added to the Form's Controls collection. Note that without adding the WebDocumentExporter to the Form, it doesn't have access to your CSS Styles. I recommend making this change to your sample to enable the behavior you wish to have with the RunTime instance.
Thanks Jose for taking the extra time to dig into this a bit deeper, I really appreciate it. I've updated the sample, and adding the WebDocumentExporter to Page.Form.Controls works.
The sad thing is, I can't get it to work in my actual project. The export is mostly identical and so are the styles. I've been trying to reproduce it in the sample code to isolate the problem but I cannot. If I do I'll post it here.
Thank you for the update.
I will be looking forward to reviewing the sample when it becomes available.
Dirk,
For the issue in your application, you could test setting runat="server" on the style tag and see if that changes the behavior.
You could also check the Page property of the exporter to verify that it isn't null since the exporter needs a reference to the page to find the styles. Note that this is why the adding of the exporter to the form resolved the issue in the sample.
If you find that the page is not null and runat="server" doesn't make a difference, then you may want to download our source code and debug using that as you may be able to better see why the styles aren't loaded.
Let me know if you have any questions with this matter.