PDF export quirk and customization

69 posts, 0 answers
  1. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 14 Dec 2010 Link to this post

    Hi, I use client-side binding and export to PDF works strange:

    below normal data-filled rows it shows a row with "No data" text.

    Where is that from? Could it have something to do with custom paging?

    Also, on page load, before the data is received from webservice, the grid shows tons of empty rows.
    I've seen somewhere on forum I should put [e.Item.Display = 'none'] to fix this. Is there a better approach? As i understand, this just hides these rows vis display: none, but markup anyway is huge!

    And more questions about PDF customization: why
    this.MasterTableView.ItemStyle.BorderStyle
    assigning in PDF export event does not work? I want to remove this ugly double border around some cells in PDF and remain single border only around data cells.
    Is there a way to acquire somehow CSS class data in ItemCreated event and 'transform' them into inline style to preserve grid outlook?
  2. Bruno
    Bruno avatar
    105 posts
    Member since:
    Mar 2008

    Posted 14 Dec 2010 Link to this post

    Alex, how did you manage to export radgrid with client-side binding? As far as I know this is not possible.
    To the second question - only the inline styles will be exported. Personally, I use the ItemCreated event to customize the item look. I pass a reference to the item to an external method that formats the cells automatically according to a predefined pattern that corresponds to the current style (skin).
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 14 Dec 2010 Link to this post

    All-in-all, i've beaten some problems, but I cannot make spacing work: neither with
    radGrid.MasterTableView.CellSpacing
    
    nor with 
    cell.Style.Add("margin""2px !important");
    
    ANd well - what about "No data" row?? What is that? I still cannot get rid of it! 
    
  5. Bruno
    Bruno avatar
    105 posts
    Member since:
    Mar 2008

    Posted 14 Dec 2010 Link to this post

    Do you have ClientDeleteColumn?
  6. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 15 Dec 2010 Link to this post

    No, I don't
  7. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 15 Dec 2010 Link to this post

    Hello Alexander,

    Could you please post your markup in this thread? I suggest that you use the "Format Code Block" tool from the toolbox above.

    Regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 15 Dec 2010 Link to this post

    Here is :
    protected void ExportToPdfClick(object sender, EventArgs e)
    {
        currentlyExportingType = DSExportType.Pdf;
        ColumnsForExportManaged = false;
        if (DataExport != null)
        {
            DataExport.Invoke();
        }
        this.ExportSettings.OpenInNewWindow = true;
        this.BorderStyle = BorderStyle.None;
        this.MasterTableView.BorderStyle = BorderStyle.None;
        this.MasterTableView.Style["border-collapse"] = "collapse";
     
        this.MasterTableView.UseAllDataFields = true;
        this.MasterTableView.AllowSorting = false;
        this.Rebind();
        this.MasterTableView.ExportToPdf();
        currentlyExportingType = null;
    }
    Also (a propos, text-transform is also ignored and not applied to headers!):
    protected override void OnItemCreated(GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            var item = e.Item as GridCommandItem;
            if (IsExport)
            {
                item.Font.Name = "Arial";
                item.Font.Bold = true;
                item.ForeColor = Color.Black;
            }
        }
        if (e.Item is GridHeaderItem)
        {
            if (IsExport)
            {
                var item = e.Item as GridHeaderItem;
                item.Font.Name = "Arial";
                item.Style["background-color"] = "#B5B5B5";
                item.Style["color"] = "#000000";
                foreach (TableCell cell in item.Cells)
                {
                    cell.Style["text-transform"] = "uppercase";
                    cell.Style["margin"] = "2px";
                    cell.Style["text-align"] = "left";
                    cell.Style["border-style"] = "1 px solid #FFFFFF";
                }
            }
        }
        if (e.Item is GridDataItem)
        {
            var item = e.Item as GridDataItem;
            if (IsExport)
            {
                item.Style.Clear();
                item.Font.Name = "Arial";
                item.Style["background-color"] = (item.ItemType == GridItemType.AlternatingItem ? "#F3F3F3" : "#E2E2E2");
                item.Style["color"] = "#000000";
                foreach (TableCell cell in item.Cells)
                {
                    cell.Style["margin"] = "2px";
                    cell.Style["text-align"] = "left";
                    cell.Style["border-style"] = "1 px solid #FFFFFF";
                }
            }
        }
    As to weirdness with "No data" row... I don't know what to post... There is a lot of code, but it's a usual calling WCF service, proper data is returned, record count is proper. However, below correct row data this "No data" is shown from somewhere... :(

    Maybe instead you could give me a hint, what could it be and what to check?

    And, by the way, why all these empty rows on initial grid load appears?
  9. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 20 Dec 2010 Link to this post

    Hello Alexander,

    Regarding the first question - you can use padding instead of margin:
    foreach (TableCell cell in item.Cells)
    {
        cell.Style["padding"] = "20px";
        cell.Style["text-align"] = "left";
        cell.Style["border-style"] = "1 px solid #FFFFFF";
    }

    As to the "No data" issue - could you please share your markup with us? This problem is probably related to your columns (there is known issue related to the GridClientDeleteColumn - as suggested by Bruno).

    Regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  10. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 24 Dec 2010 Link to this post

    Hi, I will do this later, but currently I have another, more important problem with this page.

    SO, I have ItemTemplate with some 'data field' labels inside. If corresponding data field is marked with Export attribute, when currently exporting format is not present - label is not shown.
    Here is the class for my grid:
    [KnownType(typeof(GridInfo))]
    public class Distributor
    {
        [DataContract]
        [Serializable]
        public class GridInfo
        {
            [DataMember(Name = "ID", IsRequired = false, Order = 0)]
            public int? ID { get; set; }
     
            [Export(DSExportType.Pdf, DSExportType.Excel)]
            [DataMember(Name = "Name", IsRequired = false, Order = 1)]
            public string Name { get; set; }
     
            [DataMember(Name = "JsUrlName", IsRequired = false, Order = 2)]
            public string JsUrlName { get; set; }
     
            [Export(DSExportType.Excel)]
            [DataMember(Name = "ContactEmail", IsRequired = false, Order = 3)]
            public string ContactEmail { get; set; }
        }
     
        public class GridData
        {
            public List<GridInfo> Data { get; set; }
            public int Count { get; set; }
        }
    }


    AND - attention... :) - when there are NO visible labels in the corresponding column, I want to HIDE this column! I.e. ContactEmail column should not be visible when exporting to PDF. But I don't want to bother with some predefined uniquename (or datafield) attributes in EACH (i will have tons of them) grid! They should be generated automatically and 'unify' the column and the labels inside!

    <B4Restore:DSGridView ID="dsgridDistributorView" runat="server" AutoGenerateColumns="False"
        SkinID="dsGridView" AllowPaging="true" AllowSorting="true" ExportEnabledFormats="pdf,excel"
        MasterTableViewCaption="Distributor List" MasterTableViewCssClass="bold" ProgressPanelID="ralp"
        DataBindingMethod="GetDistributorDataAndCount" DataBindingService="GridViewService" FilterGroup="Distributor">
        <MasterTableView VirtualItemCount="1000000" CommandItemDisplay="Top">
            <CommandItemTemplate>
                <B4Restore:FilterBar runat="server" />
                <B4Restore:HeaderBar runat="server" />
            </CommandItemTemplate>
            <Columns>
                <telerik:GridTemplateColumn HeaderStyle-CssClass="GridHeaderGreen la" ItemStyle-CssClass="la" HeaderText="Name" SortExpression="DSWIZARD.COMPANY.NAME">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="Name" />
                        <asp:Label runat="server" ID="JsUrlName" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-CssClass="GridHeaderGreen la" ItemStyle-CssClass="la" HeaderText="Email" SortExpression="DSWIZARD.CONTACT.EMAIL">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="ContactEmail" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </B4Restore:DSGridView>



    How to do this without assigning some UniqueNames everywhere in the grid columns? I want a GENERAL solution ;)
    protected override void OnColumnCreated(GridColumnCreatedEventArgs e)
    {
        var dataColumn = e.Column as GridTemplateColumn;
        if (dataColumn != null)
        {
            var columnUniqueName = string.Format("{0}_Column_{1:dd}", e.Column.OwnerGridID, e.Column.OrderIndex);
            dataColumn.UniqueName = columnUniqueName;
            // GOOD, but I have no access to my labels here! :(
        }
    }
    protected override void OnItemDataBound(GridItemEventArgs e)
            {
                if (!IsExport)
                {
                    return;
                }
                if (e.Item is GridDataItem)
                {
                    var item = e.Item as GridDataItem;
                    if (item.DataItem == null || item.DataItem is DataRowView)
                    {
                        return;
                    }
                    // if our data fields in the grid have Export attribute (see GridEntity.cs) - check if they should be shown (export type of the field contains currently exporting type)
                    foreach (TableCell cell in item.Cells)
                    {
                        var labels = cell.Controls.OfType<WebControl>().OfType<Label>();
                        foreach (var label in labels)
                        {
                            var property = item.DataItem.GetType().GetProperty(label.ID);
                            if (property != null)
                            {
                                var exportAttribute = ((MemberInfo)property).GetCustomAttributes(true).Where(attributeInstance => attributeInstance is ExportAttribute).FirstOrDefault();
                                if (exportAttribute != null && !((ExportAttribute)exportAttribute).ExportTypes.Contains(currentlyExportingType.Value))
                                {
                                    label.Visible = false;
                                }
                                if (label.Visible)
                                {
                                    label.Text = DataBinder.Eval(item.DataItem, label.ID).ToString();
                                }
                            }
                        }
                        //Great, but I can't access related column here :( I don't have UNIQUENAME!
                        [CURRENT COLUMN].Visible = (from label in labels where label.Visible select label).Count() > 0;
                    }
                }
            }

    The idea was to assign the same uniquename (as custom webcontrol attribute) to all labels that 'belongs' to the specific column and then check this attribute in ItemDataBound event, but how to do this?
  11. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 30 Dec 2010 Link to this post

    Hello Alexander,

    Please test the attached project at your side. It demonstrates how to hide the columns in a similar scenario.

    Regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  12. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 24 Jan 2011 Link to this post

    Hi. Thanks. This approach is ok. However, new error appears when column is made invisible:

    Grid Export to PDF error Telerik.Web.Apoc.Render.Pdf.Fonts.Type2CIDSubsetFont.get_WArray()

    I can see people here already had such problem. I discovered, that when I comment following lines - problem goes away. However, I would like to preserve these styles:

    					//item.Font.Name = "Arial";
    //item.Font.Bold = true;
    So, what is wrong?

    And please - advice me something about 'No data' text in PDF and Excel files! The markup of my grid is already shown - as you can see, there is no any especial there. No any extra-columns.
  13. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 26 Jan 2011 Link to this post

    Hello Alexander,

    Could you please try with another font? (for example Verdana or Garamond)

    As to the "No data" problem. This problem will be addressed in the next official version of RadControls for ASP.NET AJAX.

    Kind regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  14. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 31 Jan 2011 Link to this post

    Hi, I've tried with another fonts, but error is the same. Could you please also fix this issue in next build?

    Btw, now I've discovered weird bug! So, I have client-side binding and webmethod returns 4 records. But in the grid 4th record is absent! Here is HTML, copied via Firebug:

    <tr class="rgRow" id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00__0" style="display: table-row;">
        <td class="la">
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl04_Name">MASTER Software</span>
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl04_ContactEmail">master@b4restore.com</span>
                </td>
    </tr><tr class="rgAltRow" id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00__1" style="display: table-row;">
        <td class="la">
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl06_Name">DISTRIBUTOR Software</span>
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl06_ContactEmail">distributor@b4restore.com</span>
                </td>
    </tr><tr class="rgRow" id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00__2" style="display: table-row;">
        <td class="la">
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl08_Name">PARTNER Software</span>
                    <span id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00_ctl08_ContactEmail">partner@b4restore.com</span>
                </td>
    </tr><tr class="rgNoRecords" style="display:none;">
        <td colspan="1" style="text-align:left;"><div>No data</div></td>
    </tr>
    <tr class="rgAltRow" id="ctl00_ctl00_cphMain_cphMain_masterDistributorView_dsgridDistributorView_ctl00__3"><td></td></tr>

    As you can see, there is also 'No data' intruder! That might be the reason of 'No data' row in exported PDF???

    Ok, and now is corresponding dataItem output via Sys.Debug.traceDump. As you can see, there are 4 records, not 3!

    traceDump {Object}
        __type: Distributor.GridInfo:#DebriefingSoftware.Web.PresentationObjects
        ID: 1
        Name: MASTER Software
        JsUrlName: null
        ContactEmail: master@b4restore.com
     
     
     
     
    traceDump {Object}
        __type: Distributor.GridInfo:#DebriefingSoftware.Web.PresentationObjects
        ID: 3
        Name: DISTRIBUTOR Software
        JsUrlName: null
        ContactEmail: distributor@b4restore.com
     
     
     
     
    traceDump {Object}
        __type: Distributor.GridInfo:#DebriefingSoftware.Web.PresentationObjects
        ID: 4
        Name: PARTNER Software
        JsUrlName: null
        ContactEmail: partner@b4restore.com
     
     
     
     
    traceDump {Object}
        __type: Distributor.GridInfo:#DebriefingSoftware.Web.PresentationObjects
        ID: 5
        Name: CLIENT Software
        JsUrlName: null
        ContactEmail: client@b4restore.com
  15. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 03 Feb 2011 Link to this post

    Hello Alexander,

    The "No data" issue is already addressed by our developers.

    Which version of RadControls for ASP.NET AJAX is used in your project? Also, could you please post a list of the fonts that cause exceptions?

    As to the client-side databinding issue - it is hard to guess what is the root cause for this problem. Please submit a support ticket with a runnable demo attached and I will debug it locally.

    Kind regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  16. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 03 Feb 2011 Link to this post

    Greetings, version is
    2010.2.826.40
    I know it may be not the latest, but sometimes we meet incompatibilities when running newer version, so we are not in a hurry to replace the version when it appears... :)
    Concerning fonts. These are Arial, Garamond and Verdana I've tried.

    I will send support ticket, maybe guys will find the reason of problem with fonts - maybe i'm doing something wrong - or other stuff, i am doing incorrect related to client-side binding. Because it's really quite advanced version of that simple sample, i've seen on your site ;)

    add-on: today i've tested the grid and see weird thing:
    first of all, I have a special user setting: page size for the grid. On initial load, in server side code, grid.PageSize and grid.MasterTableView.PageSize are assigned this number. Then i call web method for filling the grid, do client-side databinding (dataBind()) and other staff. Also, i set PageSize and CurrentPageIndex in my pager when I change page size or move across the pages with arrow buttons.
    However, actually
    tableView.get_pageCount()
    returns incorrect value! It gives me INITIAL page count, not page count of REAL current state of the grid! However, I cannot see client-side setters for page count and no anything for record count. So, I suppose, this should be refreshed manually, when I do dataBind(), but this does not happen on client side...
  17. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 09 Feb 2011 Link to this post

    Hello Alexander,

    About the PDF issue: The provided information is sufficient. There is no need to submit a support ticket at this point. I will keep you posted.

    As to the client-side issue: The page count is automatically calculated according to the page size and the item count (virtualItemCount)

    Kind regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  18. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 09 Feb 2011 Link to this post

    Daniel,

    ok, i've added the line for setting virtual item count:

    tableView.set_dataSource(result.Data); // was before
    tableView.set_virtualItemCount(result.Count); // added now

    but nothing changed: page count is still incorrect... :(
  19. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 14 Feb 2011 Link to this post

    Hello Alexander,

    You can use the following links as a starting point:
    Programmatic Binding demo
    Client-side binding

    I hope this helps.

    Best regards,
    Daniel
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  20. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 23 Feb 2011 Link to this post

    Hi, Daniel.

    I've already read all these tutorials before :)
    Btw, I don't use PageMethods, I use Sys.Net.WebServiceProxy.invoke. And I have everything working properly, except this pager thing...

    add-on:

    i've added this into _Succeeded method:
    tableView.RecordCount = result.Count;

    and this into SelectedIndexChanged method:
    tableView.set_virtualItemCount(tableView.RecordCount);

    So, I've added new property to tableView (strange, there is no record count property in tableView) and now it seems to work...
    But I am still not sure everything is FULLY correct...
  21. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 23 Mar 2011 Link to this post

    Hi,

    i have additional quirks when trying to do PDF export.

    1) text in some columns overflows cell limits (to the right) - and after all, it looks like for some reason the same width is automatically assigned to all columns
    2) can't manage command item template content (I have a header text for the grid there) look properly: it occupies some very small width and then wraps! I tried to set style white-space: none, also tried to indicate 100%-width, but latter caused exception...

    How to fix these?
  22. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 28 Mar 2011 Link to this post

    Hello Alexander,

    1) Cell contents will overflow when you have long text without whitespace characters inside.
    PDF export help topic

    2) You have to call PrepareItemStyle method for this item as demonstrated in the online demo:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            e.Item.PrepareItemStyle(); //needed to span the image over the CommandItem cells
        }
    }

    Export to PDF

    Regards,
    Daniel
    the Telerik team
  23. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 01 Apr 2011 Link to this post

    Thank you, second bug is fixed, but as to first one...
    Well, yes, I do have text with no space - long names. But I cannot predict, how many symbols it will include in every given case. It depends on what entity is bound to that grid, etc. I want some common logic. I tried the following code, but it did not work:
    protected override void OnItemDataBound(GridItemEventArgs e)
    {
        base.OnItemDataBound(e);
     
        if (IsExport)
        {
            if (e.Item is GridDataItem)
            {
                var item = e.Item as GridDataItem;
                if (item.DataItem == null || item.DataItem is DataRowView)
                {
                    return;
                }
                foreach (TableCell cell in item.Cells)
                {
                    cell.ControlStyle.Width = Unit.Pixel(cell.Text.Length * 10);
                }
                item.PrepareItemStyle();
            }
        }
    }
  24. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 06 Apr 2011 Link to this post

    Hello Alexander,

    I'm afraid it would be almost impossible to calculate the length of the string except if you use monospaced-type font (fixed pitch) like Courier New, Courier, Consolas, Lucida Console, Monaco, Terminal, etc.

    Best regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  25. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 08 Apr 2011 Link to this post

    Ok, at least i would like to put approximate length.

    Variant with fixed width is unacceptable: i have dozens of columns and dozens of entities and I never know what width should be!

    So what do you offer? I would like to estimate width based on the actual text data, like in my example, but it could be not a text only, but href or something, when not whole innerHTML should be taken into account, but only displayed text.
  26. Jesper Matthiesen
    Jesper Matthiesen avatar
    8 posts
    Member since:
    Oct 2008

    Posted 08 Apr 2011 Link to this post

    In general, i've solved the problem. Here is the code:

    if (IsExport)
    {
        const int charWidth = 10;
        var innerTextPattern = new Regex("\\>(.+)\\<\\/");
     
        foreach (GridColumn column in MasterTableView.Columns)
        {
            if (column is GridEditableColumn)
            {
                var columnWidth = 0;
                var currentlyExportingTypes = column.CurrentFilterValue.GetTypesFromSeparatedString<DSExportType>();
     
                if (currentlyExportingTypes.Count > 0 && !currentlyExportingTypes.Contains(_currentlyExportingType.Value) || column.HeaderText == "#")
                {
                    column.Visible = false;
                }
     
                if (column.Visible)
                {
                    foreach (GridDataItem dataItem in MasterTableView.Items)
                    {
                        var labelLengths = 0;
                        if (column is GridTemplateColumn)
                        {
                            var labelTexts = (from label in dataItem[column.UniqueName].Controls.OfType<WebControl>().OfType<Label>() select label.Text);
                            foreach (var labelText in labelTexts)
                            {
                                var innerTextPatternMatches = innerTextPattern.Matches(labelText);
                                if (innerTextPatternMatches.Count > 0)
                                {
                                    labelLengths += (from Match innerTextPatternMatch in innerTextPatternMatches
                                                     where innerTextPatternMatch.Success
                                                     select innerTextPatternMatch.Groups[1].Value
                                                     into innerText select innerText.Length).Sum();
                                }
                                else
                                {
                                    labelLengths += labelText.Length;
                                }
                            }
                        }
                        else
                        {
                            var innerTextPatternMatches = innerTextPattern.Matches(dataItem[column.UniqueName].Text);
                            if (innerTextPatternMatches.Count > 0)
                            {
                                labelLengths += (from Match innerTextPatternMatch in innerTextPatternMatches
                                                 where innerTextPatternMatch.Success
                                                 select innerTextPatternMatch.Groups[1].Value
                                                 into innerText select innerText.Length).Sum();
                            }
                            else
                            {
                                labelLengths = dataItem[column.UniqueName].Text.Length;
                            }
                        }
                        var currentColumnWidth = labelLengths * charWidth;
                        if (columnWidth < currentColumnWidth)
                        {
                            columnWidth = currentColumnWidth;
                        }
                    }
                    column.HeaderStyle.Width = Unit.Pixel(columnWidth);
                }
            }
        }
        _currentlyExportingType = null;
    }

    Btw, have you solved the problem with cookieless session when exporting in your latest release? This, may i have images preserved when exporting cookieless session page grid data into PDF? I cannot turn session off for this page, because i get data from session
  27. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2011 Link to this post

    Small correction

    column.HeaderStyle.Width = Unit.Pixel(Math.Max(columnWidth, column.HeaderText.Length * charWidth))
  28. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 10 Apr 2011 Link to this post

    Hello Jesper,

    Thank you for sharing your code with our community. You could make a simple test project and submit it as a code-library.
    Using the Code Library
    Code Library

    As to your question - the cookieless-related problem is already fixed. Let me know if you experience any issues when exporting images in cookieless mode.

    Regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  29. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 13 Apr 2011 Link to this post

    I hoped, that problem with images have been fixed in latest version, but alas...
    I have the same problem as here

    Why is that? When will be next release, fixing that?
  30. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 18 Apr 2011 Link to this post

    Hello Alexander,

    This issue was fixed in Q1 2011 SP1 (released on Apr 13, 2011). If you still experience problems in this scenario, please isolate the problem in a sample project. This way we will be able to investigate the cause locally.
    Isolating a problem in a sample project

    Regards,
    Daniel
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  31. Alexander
    Alexander avatar
    152 posts
    Member since:
    Jun 2012

    Posted 29 Apr 2011 Link to this post

    Hi, I do use latest version, but the problem remains.

    Maybe i'm doing wrong something? I use client-side binding and one of columns is bound to the following property:

    [DataMember]
    public string MappedVdisksCountImg
    {
        get
        {
            if (MappedVdisksCount.HasValue && MappedVdisksCount.Value > 0)
            {
                return "<img src='" + HttpContext.Current.GetWebRoot() + "/images/bullet_ball_green.png' />";
            }
     
            return "<img src='" + HttpContext.Current.GetWebRoot() + "/images/bullet_ball_red.png' />";
        }
        set { }
    }

    Markup is ok, image is displayed:
    <td class="ca">
                        <span id="ctl00_cphMain_tc1_ctl00_ca1_ctl00_svc2HostView_gridClient_ctl00_ctl04_MappedVdisksCountImg"><img src="https://localhost/Client.TSM-SVC/images/bullet_ball_green.png"></span>
                    </td>


    But the error is following when I press my export button:
    System.SystemException: Error while creating area : Encountered web exception while fetching image from file:///C:/TFS/WizardsFramework/Main/Source/B4Restore.Web.Client.TSM-SVC/Pages/SVC2/https://localhost/Client.TSM-SVC/images/bullet_ball_green.png: The given path's format is not supported.


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017