Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
1.8K+ views

I have a button inside RadAjaxPanel and i want to export it to the Excel Sheet, Below is the code i had written to do this task. If i removed the RadAjaxpanel then i can export the datatable into excel sheet. But when trying to export  it to Excel using radajax panel, I'm getting this error: Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."

<telerik:RadAjaxPanel ID="mainPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel">
        <table class="reportSearch">
            <tr>
                <td>
                    <telerik:RadButton ID="btnExcelDetail" runat="server" Text="Excel" OnClick="btnExcelDetail_Click" ValidationGroup="SearchValidation" ClientEvents-OnRequestStart="requestStart">
                            <Icon PrimaryIconUrl="~/App_Themes/RnDThemes/images/insert_table_on.gif" PrimaryIconHeight="15" />
                        </telerik:RadButton>
                </td>
                <td>
                </table>
</telerik:RadAjaxPanel>
<script type="text/javascript">
function requestStart(sender, args) {               
                if (args.get_eventTarget().indexOf("btnExcelDetail") >= 0)
                    args.set_enableAjax(false);
            }
</script>
public void ExporttoExcel(DataTable table, string filename)
    {
        try
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + "");
            HttpContext.Current.Response.Charset = "utf-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
            HttpContext.Current.Response.Write("<TABLE border='1' bgColor='#ffffff' " +
              "borderColor='#000000' cellSpacing='0' cellPadding='0' " +
              "style='font-size:10.0pt;background:white;'><TR>");
            int columnscount = table.Columns.Count;
            for (int j = 0; j < columnscount; j++)
            {
                HttpContext.Current.Response.Write(@"<TD><B>" + table.Columns[j].ToString() + "</B></TD>");
            }
            HttpContext.Current.Response.Write("</TR>");
            foreach (DataRow row in table.Rows)
            {
                HttpContext.Current.Response.Write("<TR>");
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    if (row[i].ToString().Trim().Length > 1 && row[i].ToString().Trim().StartsWith("0") && row[i].GetType().Name=="String")
                        HttpContext.Current.Response.Write("<TD style=\"mso-number-format:\\@\">");
                    else
                        HttpContext.Current.Response.Write("<TD>");
                    HttpContext.Current.Response.Write(row[i].ToString());
                    HttpContext.Current.Response.Write("</TD>");
                }
                HttpContext.Current.Response.Write("</TR>");
            }
            HttpContext.Current.Response.Write("</TABLE>");
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.SuppressContent = true;
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }       
        catch (Exception) { }
Viktor Tachev
Telerik team
 answered on 30 Nov 2016
0 answers
174 views

Hi, everyone,

As far as I know, RadEditor doesn't have a page break functionality when HTML is exporting to DOCX. I've found a solution for this:

 

DocxFormatProvider provider = new DocxFormatProvider();
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();

List<string> result = this.PrepareStringToExport(htmlPage); //result is a list with divided "pages"
RadFlowDocument newDoc = new RadFlowDocument();
RadFlowDocumentEditor newEditor = new RadFlowDocumentEditor(newDoc);
RadFlowDocument document;
foreach(string element in result)
{
document = new RadFlowDocument();
document = htmlProvider.Import(element);
newEditor.InsertDocument(document);
newEditor.InsertBreak(BreakType.PageBreak);
}
byte[] byteArray = provider.Export(newEditor.Document);
string fileName = "filename.docx";
Utils.SendBytesAsFileToClientWithAjax(Response, fileName, byteArray);

 

If there is a cleaner solution, let me know

 

Best regards

Marcin

Marcin
Top achievements
Rank 1
 asked on 30 Nov 2016
7 answers
254 views

Hello,

I have an OrgChart and a couple of labels and an image that I want to export to PDF using the RadClientExportManager.
Code .aspx: 

table id="exporttopdf">
    <tr>
        <td>
 
            <asp:image runat="server" imageurl="~/styles/images/logo.png" />
            <asp:panel runat="server" id="Panel1" visible="false">
                            <span class="content">
                                GRUPP: <asp:Label runat="server" ID="Label1"></asp:Label><br />
                                DATUM: <asp:Label runat="server" ID="Label2"></asp:Label>
                            </span>
                        </asp:panel>
        </td>
    </tr>
    <tr>
        <td>
            <telerik:RadOrgChart ID="RadOrgChart2" runat="server" GroupColumnCount="1" DisableDefaultImage="true">
                <GroupEnabledBinding>
                    <NodeBindingSettings DataFieldID="ID" DataFieldParentID="ParentID" />
                    <GroupItemBindingSettings DataFieldNodeID="NodeID" DataFieldID="ID" DataTextField="Text" />
                </GroupEnabledBinding>
            </telerik:RadOrgChart>
        </td>
    </tr>
</table>

However my swedish special characters doesn't show properly in the PDF.
I've been using this demo http://docs.telerik.com/devtools/aspnet-ajax/controls/clientexportmanager/how-to/exporting-special-characters
and it works as expected.

What do I need to do to get it to work with the orgChart?

Any suggestions appreciated

Regards

Janne

Veselin Tsvetanov
Telerik team
 answered on 30 Nov 2016
19 answers
1.1K+ views
Please help me how to add a row in Header and merge some cells in row of Header

RJ
Top achievements
Rank 1
 answered on 30 Nov 2016
5 answers
648 views
I've a rad grid and I want to set the focus on a specified row of the grid using javascript.

I've done this function:


     function setActiveRow(p) {
         var grid = $find("<%=RadGridDati.ClientID%>");
         var masterTableView = grid.get_masterTableView();
         masterTableView.get_dataItems()[p].get_element().cells[0].focus();
     }

where p is the row number I want to set the focus.
It's running correctly with Explorer but not with Firefox and Crome.
Some ideas?

Thanks in advan ce
Eyup
Telerik team
 answered on 30 Nov 2016
2 answers
61 views

I noticed that the markers on the map looks mispositioned on many devices, like shifted to north/east.

I got this problem with my Android phone and even with a Surface pro, whatever the browser I 'm using.

You can see it even with the online demo:
http://demos.telerik.com/aspnet-ajax/map/examples/overview/defaultcs.aspx

On PC:
https://i.snag.gy/IzuexH.jpg

On my phone:
https://i.snag.gy/XTwYrK.jpg

I think it's just a css issue with the markers. I really need a quick solution to the problem. Any ideas? :/

zaza
Top achievements
Rank 1
 answered on 29 Nov 2016
1 answer
1.1K+ views

Hi Team,

I have a Radgrid which has DateTime Column with enable range filter. I am using AllowCustomPaging="True" And I am displaying the date as "24/11/2016 15:31:15" and I want that when I choose from date and To date the filter expression should format the filter date.

For example From date is "23/11/2016" and To Date is "24/11/2016" then it should change to "20161123" and "20161124" before passing to database.

Could you please help me on this.

~

Sandeep

Vasil
Telerik team
 answered on 29 Nov 2016
1 answer
143 views

Hello,

In the new version of UI for ASP.NET AJAX, v2016.3.1027,  the RadMenu no longer closes in Internet Explorer 11 when using the code below. When selecting "Action 2" under "Actions", the javascript code in the OnClientItemClicking handler would close the menu, but now the menu stays visible.  It had been working up to this point after several years, and still works in other browsers (Edge, Chrome).  Please Advise.

Thank You!

 

01.<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="RadMenuNotClosing.WebForm1" %>
02.<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
03.<!DOCTYPE html>
04. 
06.<head runat="server">
07.    <title></title>
08.</head>
09.<body>
10.    <form id="form1" runat="server">
11.        <telerik:RadScriptManager ID="rsm" runat="server">
12. 
13.        </telerik:RadScriptManager>
14.    <div>
15.        <telerik:RadMenu ID="rmTest"
16.                runat="server"
17.            OnClientItemClicking="MenuItemClicking"
18.            CollapseAnimation-Duration="0"
19.            ExpandAnimation-Duration="0"
20.            CollapseAnimation-Type="None"
21.            ExpanDelay="0"
22.            CollapseDelay="0"
23.            ClickToOpen="true"
24.            >
25.            <Items>
26.                <telerik:RadMenuItem Text="File">
27.                    <Items>
28.                        <telerik:RadMenuItem Text="Exit">
29.                        </telerik:RadMenuItem>
30.                    </Items>
31.                </telerik:RadMenuItem>
32.                <telerik:RadMenuItem Text="Actions">
33.                    <Items>
34.                        <telerik:RadMenuItem Text="Action 1" Value="Action1" >
35.                        </telerik:RadMenuItem>
36.                        <telerik:RadMenuItem Text="Action 2" Value="Action2"  >
37.                        </telerik:RadMenuItem>
38.                    </Items>
39.                </telerik:RadMenuItem>
40.            </Items>
41.        </telerik:RadMenu>
42.        <script type="text/javascript">
43.            function MenuItemClicking(sender,args)
44.            {
45.                var item = args.get_item();
46.                var itemValue = item.get_value();
47.                if (itemValue == "Action2")
48.                {
49.                    var txt = document.getElementById("txtText");
50.                    txt.value = "Action 2 taken";
51.                    args.set_cancel(true);
52.                    sender.close();
53.                    return;
54.                }
55.            }
56.        </script>
57.    </div>
58.        <br />
59.        <br />
60.        <br />
61.        <asp:TextBox ID="txtText" runat="server" Text="-" ClientIDMode="Static">
62.        </asp:TextBox>
63.    </form>
64.</body>
65.</html>
Dimitar
Telerik team
 answered on 29 Nov 2016
0 answers
95 views

I'm populating a box plot chart with a data table created from a sequel query. The query has an outliers field:

SELECT m.[periodEnd], m.[lower], m.[Q1], m.[Mean], m.[Median], m.[Q3], m.[upper],
[outliers] =
STUFF(
(SELECT ','+ CAST([DollarRepayment] AS varchar(12)) FROM #boxPlotList mm WHERE (mm.[DollarRepayment] < m.[lower]
OR mm.[DollarRepayment] > m.[upper]) AND mm.[periodEnd] = m.[periodEnd] FOR XML PATH('')),1,1,''
)
FROM #boxPlotDollarRepayments m
ORDER BY [periodEnd]

The outliers column shows like this:

10000.00,543901.00,783930.00,25325.00,403267.00,922911.00,850953.00,39815.00,20697.00,31654.00,39540.00,1385234.00,29954.00,507726.00

The code behind picks up the data table and binds it to the chart. The HTML looks like this:

<telerik:RadHtmlChart ID="RadHtmlChart5" runat="server" Width="100%" Height="500px">
<PlotArea>
<Series>
<telerik:BoxPlotSeries DataLowerField="lower" DataQ1Field="Q1" DataMeanField="Mean" DataMedianField="Median" DataQ3Field="Q3" DataUpperField="upper" DataOutliersField="outliers">
<OutliersAppearance MarkersType="Circle"></OutliersAppearance>
<ExtremesAppearance MarkersType="Cross"></ExtremesAppearance>
</telerik:BoxPlotSeries>
</Series>
<YAxis>
<TitleAppearance Text="Repayment Amount" RotationAngle="-90"></TitleAppearance>
<LabelsAppearance DataFormatString="{0:C0}"></LabelsAppearance>
</YAxis>
<XAxis DataLabelsField="periodEnd">
<TitleAppearance Text="Month Ending"></TitleAppearance>
<LabelsAppearance RotationAngle="-90"></LabelsAppearance>
</XAxis>
</PlotArea>
<ChartTitle Text="Repayments Plotting">
<Appearance Align="Center">
<TextStyle Bold="true" FontSize="16"/>
</Appearance>
</ChartTitle>
</telerik:RadHtmlChart>

If I remove the outliers column from the stored procedure and the chart tag, it works. If I put the outliers column in the stored procedure, whether I specify DataOutliersField or not in the BoxPlotSeries tag, the chart fails: chart displays the outliers all at 0 and 1 for each axis item, and the boxes, mean, median, upper and lower bounds do not appear.

Can anyone tell me what I am doing wrong?

 

 

Ralph
Top achievements
Rank 1
 asked on 29 Nov 2016
2 answers
272 views

Hi: Here are a part of RadGrid ! when I in edit & insert mode, I want hide Id (because it PK and auto increment), How Can I do ?

<Columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>

<telerik:GridBoundColumn DataField="Id" HeaderText="Id" SortExpression="Id"
UniqueName="Id" Visible="false" >
</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Catagory" HeaderText="題目類別" SortExpression="Catagory"
UniqueName="Catagory">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CataPercentage" HeaderText="百分比" SortExpression="CataPercentage"
UniqueName="CataPercentage">

</telerik:GridBoundColumn>
<telerik:GridButtonColumn Text="Delete" CommandName="Delete" />
                </Columns>

Liu
Top achievements
Rank 1
 answered on 28 Nov 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?