This is a migrated thread and some comments may be shown as answers.

RadGrid display issue in Google Chrome

4 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35) asked on 18 Mar 2011, 11:57 AM
Hi All,

Have two RadDatePicker and a RadGrid, which works fine.

Have to enter the Start Date and End Date, and click the Tick button.

while the Tick button is clicked the RadGrid displays with Datas.

Works fine in FireFox and IE

But in Google Chrome RadGrid is not displayed. The cursor points to the Start Date.

Have attached the screen shot.

Is there any option to rectify this

Thanking You

-Anto

4 Answers, 1 is accepted

Sort by
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 18 Mar 2011, 12:01 PM
Hi All

Here I all copied the aspx page with JavaScript

<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="TimesheetByProject.aspx.cs"
    Inherits="ProductsTimesheets.TimesheetByProject" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
    <qsf:HeadTag runat="server" ID="Headtag2"></qsf:HeadTag>
    <title>Report by User</title>
    <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<telerik:RadScriptBlock ID="RadScriptRptBlock1" runat="server">
 
    <script type="text/javascript">
         
  // Gan - 21/03/09 - To Check The Start And End Date Before Report Exporting     
  function OnClientRptBtn_Click()
    {
        // Function To Check The Start And End Date Before Report Exporting - Gan - 21/03/09
        var x = document.getElementById("rdpcStartDate");
        var y = document.getElementById("rdpcEndDate");
            if (x.value == "" || x.value == null)
                {
                    radalert("Please Specify Start Date",220,100);
                    //x.focus(); // Focus not working - Control Not Enabeld or Invisible
                    return false;
                }
            if (y.value == "" || y.value == null)
                {
                    //y.focus();
                    radalert("Please Specify End Date",220,100);
                    return false;
                }
                //Anto
                DateCompare();
                if (DateFlag == true  )
                {
                    DateFlag = false;
                    return false;                   
                      
                }
                //Anto
    }
     
    //Anto
            var DateFlag =false;
            function DateCompare()
            {
                DetectBrowser();
                if (isFF)
                {
                    var a = new Date(document.getElementById("rdpcStartDate").value.replace('-', ',', 'g'));
                    var b = new Date(document.getElementById("rdpcEndDate").value.replace('-', ',', 'g'));
                }
                else
                {
                    var a = new Date(document.getElementById("rdpcStartDate").value.replace('-',','));
                    var b = new Date(document.getElementById("rdpcEndDate").value.replace('-',','));
                }
                var k = 1000*60*60*24;
                if (Math.ceil((b-a)/k) < 0)
                {
                    radalert("End Date cannot be lesser then the Start date",320,100);
                    DateFlag = true;
                }
            }
            //Anto
            //Dev
            var isIE = false;
            var isFF = false;
            var isOP = false;
            var isSafari = false;
            function DetectBrowser()
            {
                var val = navigator.userAgent.toLowerCase();
                if(val.indexOf("firefox") > -1)
                {
                    isFF = true;
                }
                else if(val.indexOf("opera") > -1)
                {
                    isOP = true;
                }
                else if(val.indexOf("msie") > -1)
                {
                    isIE = true;
                }
                else if(val.indexOf("safari") > -1)
                {
                    isIE = true;
                }
            }
            //Dev
            function CloseWindow1()
            {
                document.getElementById("Btngenerateemail").click();
            }
 
    </script>
 
</telerik:RadScriptBlock>
<telerik:RadWindowManager ID="Singleton" runat="server">
</telerik:RadWindowManager>
<body class="BODY">
    <form id="form1" runat="server">
     
    <asp:ScriptManager runat="server" ID="ScriptManager1">
    </asp:ScriptManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Top="50px" Skin="Vista">
        <Windows>
            <telerik:RadWindow Skin="Vista" ID="winAlert" runat="server" Title="User List Dialog"
                Height="40px" Width="100px" Left="150px" ReloadOnShow="true" Modal="true" Animation="Resize" />
        </Windows>
    </telerik:RadWindowManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1" IsSticky="true" Style="margin-top: 100px;
        margin-left: 300px; position: absolute; z-index: 100" Transparency="30" HorizontalAlign="Center"
        MinDisplayTime="500" BackColor="#E0E0E0">
        <asp:Image runat="server" ID="LoadingImage1" ImageUrl="~/ippc/Image/Loading.gif"
            AlternateText="Loading..." />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager VisibleTitlebar="true" VisibleStatusbar="false" RestrictionZoneID="RestrictionZone"
        Width="644px" Height="98%" Modal="true" ID="rwmTemp" runat="server" DestroyOnClose="true"
        Behaviors="Close, Move, Resize">
    </telerik:RadWindowManager>
    <div class="module" style="height: 85px; width: 92%">
        <asp:CheckBox ID="CheckBox1" Text="Export only data" runat="server"></asp:CheckBox>
        <br />
        <asp:CheckBox ID="CheckBox2" Text="Ignore paging (exports all pages)" runat="server">
        </asp:CheckBox>
        <br />
        <%--Anto--%>
        <%--<asp:CheckBox ID="CheckBox3" Text="Open exported data in new browser window" runat="server">
        </asp:CheckBox>
        <br />--%>
        <br />
        <asp:Button ID="btnExcel" CssClass="button" Width="135px" Text="Export to Excel"
            runat="server" OnClick="btnExcel_Click" OnClientClick="return OnClientRptBtn_Click()">
        </asp:Button>
        <%-- <asp:Button ID="Button4" CssClass="button" Width="100px" Text="Export to ExcelML"
            OnClick="Button4_Click" runat="server"></asp:Button>--%>
        <asp:Button ID="btnWord" CssClass="button" Width="135px" Text="Export to Word" runat="server"
            OnClick="btnWord_Click" OnClientClick="return OnClientRptBtn_Click()"></asp:Button>
        <asp:Button ID="btnCsv" CssClass="button" Width="135px" Text="Export to CSV" runat="server"
            OnClick="btnCsv_Click" OnClientClick="return OnClientRptBtn_Click()"></asp:Button>
        <asp:Button ID="btnPdf" CssClass="button" Width="135px" Text="Export to Pdf" runat="server"
            OnClick="btnPdf_Click" OnClientClick="return OnClientRptBtn_Click()"></asp:Button>
        <%--Leo--%>
        <%--Start of Add new Button to Export PDF with Mail --%>
        <asp:Button ID="ExportToMail" CssClass="button" Width="135px" Text="Send as Mail"
            runat="server" OnClick="ExportToMail_Click" OnClientClick="return OnClientRptBtn_Click()">
        </asp:Button>
        <asp:Button ID="Btngenerateemail" runat="server" OnClick="ManualExportToMail" Style="display: none">
        </asp:Button>
        <%--End of Add new Button to Export PDF with Mail --%>
    </div>
    <table width="70%">
        <%--Anto--%>
        <%--<tr>
            <td colspan="3">
                <asp:Label ID="lblErrMsg" runat="server" ForeColor="Tomato" Font-Bold="true"></asp:Label>
            </td>
        </tr>--%>
        <tr>
            <td>
                <asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
                <telerik:RadDatePicker ID="rdpcStartDate" runat="server" Skin="WebBlue">
                    <DateInput ID="DateInput1" runat="server" MaxLength="10" Skin="WebBlue" DisplayDateFormat="dd MMM yyyy"
                        DateFormat="dd/MM/yyyy" EnabledStyle-HorizontalAlign="Right">
                    </DateInput>
                </telerik:RadDatePicker>
            </td>
            <td>
                <asp:Label ID="lblEndDate" runat="server" Text="End Date"></asp:Label>
                <telerik:RadDatePicker ID="rdpcEndDate" runat="server" Skin="WebBlue">
                    <DateInput ID="DateInput2" runat="server" MaxLength="10" Skin="WebBlue" DisplayDateFormat="dd MMM yyyy"
                        DateFormat="dd/MM/yyyy" EnabledStyle-HorizontalAlign="Right">
                    </DateInput>
                </telerik:RadDatePicker>
            </td>
            <td>
                <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel6" LoadingPanelID="LoadingPanel1">
                    <%--OnClientClick is been changed due to getting the alert message by Anto 31/03/2009--%>
                    <asp:ImageButton ID="ibtnShow" runat="server" ImageAlign="Middle" ImageUrl="~/ippc/Image/Update.gif"
                        ToolTip="Show" OnClick="ibtnShow_Click" OnClientClick="return OnClientRptBtn_Click()">
                    </asp:ImageButton>
                </telerik:RadAjaxPanel>
            </td>
        </tr>
        <%--Anto--%>
        <%--<tr>
            <td colspan="3">
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="rdpcStartDate"
                    ControlToValidate="rdpcEndDate" Display="Dynamic" ErrorMessage="End Date cannot be lesser then the Start date"
                    Operator="GreaterThanEqual" Type="Date"></asp:CompareValidator>
            </td>
        </tr>--%>
    </table>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gridProjectRpt">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridProjectRpt" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <table>
        <tr>
            <td>
                <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ibtnShow" EventName="Click" />
                    </Triggers>
                    <ContentTemplate>
                        <telerik:RadGrid ID="rgvReport" ShowGroupPanel="true" AutoGenerateColumns="False"
                            ShowFooter="True" runat="server" GridLines="Both" BackColor="White" AllowPaging="True"
                            PageSize="30" Skin="WebBlue" Width="718px" Height="263px" BorderColor="White"
                            OnExcelMLExportRowCreated="rgvReport_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="rgvReport_ExcelMLExportStylesCreated"
                            OnNeedDataSource="rgvReport_NeedDataSource" OnItemDataBound="rgvReport_ItemDataBound"
                            OnGridExporting="rgvReport_GridExporting" OnCustomAggregate="rgvReport_CustomAggregate">
                            <HeaderContextMenu Skin="WebBlue">
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                            </HeaderContextMenu>
                            <MasterTableView ShowGroupFooter="true" Width="97%">
                                <%--<RowIndicatorColumn>
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>--%>
                                <GroupByExpressions>
                                    <telerik:GridGroupByExpression>
                                        <SelectFields>
                                            <telerik:GridGroupByField FieldAlias="User" FieldName="User" />
                                        </SelectFields>
                                        <GroupByFields>
                                            <telerik:GridGroupByField FieldName="User" />
                                        </GroupByFields>
                                    </telerik:GridGroupByExpression>
                                </GroupByExpressions>
                                <SortExpressions><telerik:GridSortExpression FieldName="StartDate" SortOrder="Ascending" /></SortExpressions>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="ProjectName" Aggregate="CountDistinct" FooterText="Total : "
                                        HeaderText="Project Name" UniqueName="ProjectName" HeaderStyle-Width="20%" ItemStyle-Width="20%">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="User" Aggregate="CountDistinct" FooterText=" "
                                        HeaderText="Name" UniqueName="User" HeaderStyle-Width="20%" ItemStyle-Width="20%">
                                    </telerik:GridBoundColumn>
                                    <%--<telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name">
                                            </telerik:GridBoundColumn>--%>
                                    <telerik:GridBoundColumn DataField="StartDate" HeaderText="Date" DataFormatString="{0:MM/dd/yyyy}"
                                        UniqueName="StartDate" ItemStyle-Width="10%" HeaderStyle-Width="10%">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Hours" HeaderText="Hours" HtmlEncode="true" FooterText=" "
                                        Aggregate="Sum" UniqueName="Hours" ItemStyle-Width="10%" HeaderStyle-Width="10%">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description"
                                        HeaderStyle-Width="30%" ItemStyle-Width="30%">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <ExpandCollapseColumn>
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
                            </MasterTableView>
                            <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                                <Pdf AllowAdd="true" AllowCopy="true" AllowModify="true" AllowPrinting="true" Author="Anonymous"
                                    Keywords="None" PageBottomMargin="0.5in" PageLeftMargin="0.5in" PageRightMargin="0.5in"
                                    PageTopMargin="1in" PageTitle="Hours Vs Project Report" Subject="RadGrid Export"
                                    Title="RadGrid export" PageHeight="8.3in" PageWidth="11.7in" />
                            </ExportSettings>
                            <ClientSettings AllowDragToGroup="True">
                                <Resizing AllowColumnResize="true" AllowRowResize="false" ResizeGridOnColumnResize="false" />
                                <Scrolling AllowScroll="true" />
                                <Selecting AllowRowSelect="true" />
                            </ClientSettings>
                            <FilterMenu Skin="WebBlue">
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                            </FilterMenu>
                            <EditItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                        </telerik:RadGrid>
                        <%--        <telerik:RadGrid ID="rgvReport" runat="server" Height="250px"  Width="700px"
                    AutoGenerateColumns="true" BorderWidth="0px" BackColor="White" 
                    ShowStatusBar="false" Skin="WebBlue"   AllowFilteringByColumn="false"
                    OnNeedDataSource="rgvReport_NeedDataSource"
                    OnColumnCreated="rgvReport_ColumnCreated" AllowMultiRowSelection="false"
                    onexcelmlexportrowcreated="rgvReport_ExcelMLExportRowCreated"
                    onexcelmlexportstylescreated="rgvReport_ExcelMLExportStylesCreated"
                    HeaderStyle-Wrap="false"
                    ItemStyle-Wrap="false"                     
                     
                    >
                    <MasterTableView AutoGenerateColumns="true"  >
                    </MasterTableView>
                    
                    <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                        <Pdf AllowAdd="false" AllowCopy="true" AllowModify="true" AllowPrinting="true" Author="Anonymous"
                            Keywords="None" PageBottomMargin="1in" PageLeftMargin="1in" PageRightMargin="1in"
                            PageTopMargin="1in" PageTitle="RadGrid export document" Subject="RadGrid Export"
                            Title="RadGrid export" PaperSize="Letter" />
                    </ExportSettings>
 
                    <ClientSettings AllowRowsDragDrop="false">
                        <Resizing AllowColumnResize="true" AllowRowResize="false" ResizeGridOnColumnResize="false" />
                        <Scrolling UseStaticHeaders="True" AllowScroll="true" />
                        <Selecting AllowRowSelect="true" />
                    </ClientSettings>
                </telerik:RadGrid>--%>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
                    SelectCommand="SELECT * FROM [TimeSheetTotalHours] WHERE ExcludeFromReports =0 and Userid=@UserID)">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="TotalHours" Name="Aggregate_Column" Type="String" />
                        <asp:Parameter DefaultValue="TimeSheetUser" Name="TableOrView_Name" Type="String" />
                        <asp:Parameter DefaultValue="AppointmentId" Name="Select_Column" Type="String" />
                        <asp:Parameter DefaultValue="UserId" Name="Pivot_Column" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <%--    </div>--%>
    
    </form>
</body>
</html>


Thanking You

-Anto
0
Vasil
Telerik team
answered on 24 Mar 2011, 09:52 AM
Hello Anto,

In the IE screenshots, above the export section there is a text "Timesheet By Project" and in the Chrome's the text is "Timesheet By Project Old". Are you sure that you are browsing the same page with the IE and the Chrome?
Could you also share with us the code-behind of the page?

Regards,
Vasil
the Telerik team
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 24 Mar 2011, 10:35 AM
Hi Vasil

Here is the cs page

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
using System.IO;
using System.Net.Mail;
using System.Net;
  
namespace ProductsTimesheets
{
    public partial class TimesheetByProject : System.Web.UI.Page
    {
        private static String UserId, CompanyId, UserName, CompanyEmail, Email, AuthenEmail, AuthenPass, AuthenHost;
        private static bool Mail;
        private static int PortNo;
        //SqlConnection con;
        //SqlDataAdapter da;
        int TotalHours = 0;
        int tmpTotalHours = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
            //Mail = false;
            if (Session["AuthenticatedUser"] == null)
                Response.Redirect("~/Admin/LoginCS.aspx");
            else
            {
                UserId = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID;
                CompanyId = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).CompanyID;
                UserName = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserFirstLastName;
  
                CompanyEmail = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).CompanyEmail;
                //CompanyEmail = "leo@impetusconsulting.net";
  
                Email = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).Email;
                AuthenEmail = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).AuthenticatedEmail;
                AuthenPass = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).AuthenticatedPassword;
                AuthenHost = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).MailHost;
                PortNo = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).PortNo;
  
            }
            //}
        }
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            if (ConfigureExport())
            {
                rgvReport.ExportSettings.FileName = "HourlyReport";
                rgvReport.MasterTableView.ExportToExcel();
                //Anto
  
                //Anto
            }
  
        }
        protected void btnWord_Click(object sender, EventArgs e)
        {
            if (ConfigureExport())
            {
                rgvReport.ExportSettings.FileName = "HourlyReport";
                rgvReport.MasterTableView.ExportToWord();
  
            }
  
        }
        protected void btnCsv_Click(object sender, EventArgs e)
        {
  
            if (ConfigureExport())
            {
                rgvReport.ExportSettings.FileName = "HourlyReport";
                rgvReport.MasterTableView.ExportToCSV();
            }
  
  
        }
  
        protected void btnPdf_Click(object sender, EventArgs e)
        {
  
            if (ConfigureExport())
            {
                //rgvReport.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML;
                CheckBox1.Checked = true;
  
                rgvReport.ExportSettings.FileName = "HourlyReport";
                rgvReport.ExportSettings.OpenInNewWindow = true;
                rgvReport.ExportSettings.Pdf.PageTitle = "Hours Vs Project Report";
                rgvReport.MasterTableView.ExportToPdf();
            }
  
        }
  
        protected void rgvReport_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)
        {
            if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.DataRow)
            {
                if (e.Row.Cells[0] != null && ((string)e.Row.Cells[0].Data.DataItem).Contains("U"))
                {
                    e.Row.Cells[0].StyleValue = "MyCustomStyle";
                }
            }
        }
  
  
  
        protected void rgvReport_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e)
        {
            foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles)
            {
                if (style.Id == "headerStyle")
                {
                    style.FontStyle.Bold = true;
                    style.FontStyle.Color = System.Drawing.Color.Gainsboro;
                    style.InteriorStyle.Color = System.Drawing.Color.Wheat;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
                else if (style.Id == "itemStyle")
                {
                    style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
                else if (style.Id == "alternatingItemStyle")
                {
                    style.InteriorStyle.Color = System.Drawing.Color.LightGray;
                    style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
                }
            }
  
            Telerik.Web.UI.GridExcelBuilder.StyleElement myStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("MyCustomStyle");
            myStyle.FontStyle.Bold = true;
            myStyle.FontStyle.Italic = true;
            myStyle.InteriorStyle.Color = System.Drawing.Color.Gray;
            myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
            e.Styles.Add(myStyle);
        }
        public void CheckDate(object source, ServerValidateEventArgs args)
        {
            if (Convert.ToDateTime(rdpcStartDate.SelectedDate.ToString()) > Convert.ToDateTime(rdpcEndDate.SelectedDate.ToString()))
            {
                args.IsValid = false;
  
            }
            else
            {
                args.IsValid = true;
            }
  
        }
        public Boolean ConfigureExport()
        {
            if (rgvReport.Items.Count > 0)
            {
                rgvReport.ExportSettings.ExportOnlyData = CheckBox1.Checked;
                rgvReport.ExportSettings.IgnorePaging = CheckBox2.Checked;
                //rgvReport.ExportSettings.OpenInNewWindow = CheckBox3.Checked;          
                rgvReport.ExportSettings.OpenInNewWindow = true;
                return true;
            }
            else
            {
                return false;
            }
  
        }
        protected void ibtnShow_Click(object sender, ImageClickEventArgs e)
        {
            if (Page.IsValid)
            {
                rgvReport.Rebind();
                //lblErrMsg.Text = "";
            }
            //Anto
            //else
            //{
            //    lblErrMsg.Text = "Start Date must be lesser then the End Date";
            //}
        }
        protected void rgvReport_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
        {
            if (e.Column is GridBoundColumn && (e.Column.IsBoundToFieldName("StartDate") || e.Column.IsBoundToFieldName("Hours")))
            {
                e.Column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                e.Column.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
            }
            else
            {
                e.Column.HeaderStyle.BackColor = System.Drawing.Color.BurlyWood;
                e.Column.ItemStyle.BackColor = System.Drawing.Color.BurlyWood;
                //e.Column.HeaderStyle.Width = 150;
                //e.Column.ItemStyle.Width = 150;
  
            }
        }
        protected void rgvReport_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            TimeSheetBL bl = new TimeSheetBL();
            rgvReport.DataSource = bl.getProjectReport(rdpcStartDate.SelectedDate.ToString(), rdpcEndDate.SelectedDate.ToString(), CompanyId, UserId);
            //DataTable dtTemp = null; 
            //DataTable dt = new DataTable(); 
            //dt = bl.getProjectReport(rdpcStartDate.SelectedDate.ToString(),rdpcEndDate.SelectedDate.ToString(), CompanyId); 
            //if (dt != null) 
            //    dtTemp = dt.Select("UserId=" + UserId).CopyToDataTable();
            //rgvReport.DataSource = dtTemp;
  
  
            //rgvReport
  
            //GridGroupByExpression exp = new GridGroupByExpression();
            //GridGroupByField Gby = new GridGroupByField();
            //Gby = new GridGroupByField();
            //Gby.FieldName = "User";
            //exp.SelectFields.Add(Gby);
  
  
  
  
        }
        protected void rgvReport_ItemDataBound(object sender, GridItemEventArgs e)
        {
            //if (e.Item is GridDataItem)
            //{
            //    GridDataItem dataItem = e.Item as GridDataItem;
            //    if (dataItem["Hours"].Text != " ")
            //    {
            //        int fieldValue = int.Parse(dataItem["Hours"].Text);
            //        TotalHours += fieldValue;
            //        //This line is to display the minutes in hour
            //        dataItem["Hours"].Text = HourConverter(fieldValue);
            //    }
            //}
            //if (e.Item is GridFooterItem)
            //{
            //    GridFooterItem footerItem = e.Item as GridFooterItem;
            //    footerItem["Hours"].Text = HourConverter(TotalHours);
            //}
        }
  
  
  
        protected void rgvReport_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
        {
  
            e.Result = HourConverter(TotalHours - tmpTotalHours);
            tmpTotalHours = TotalHours;
        }
  
        public string HourConverter(double minutes)
        {
            string Result;
            if (minutes < 60)
            {
                Result = "00:" + minutes;
            }
            else
            {
                Result = Convert.ToDouble(minutes / 60).ToString();
            }
            return Result;
        }
  
  
        //For mail concept
        protected void rgvReport_GridExporting(object source, GridExportingArgs e)
        {
            if (Mail)
            {
                try
                {
  
                    dataLayer dl = new dataLayer();
                    string FileNamePath = Server.MapPath("/") + "/Reports/TimesheetByProjectReportfor" + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID) + ".pdf";
                    // FileNamePath = "C:/Reports/TimesheetByProjectReportfor" + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID) + ".pdf";                  
                    using (FileStream fs = File.Create(FileNamePath))
                    {
                        Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                        fs.Write(info, 0, info.Length);
                        fs.Close();
  
                    }
                    MailMessage Mmsg = new MailMessage();
                    Mmsg.IsBodyHtml = true;
                    Mmsg.From = new MailAddress(Email);
                    Mmsg.To.Add(CompanyEmail);
                    Mmsg.CC.Add(Email);
  
                    //Mmsg.To.Add("leo@impetusconsulting.net");
  
                    Mmsg.Subject = "Timesheet By Project Report - " + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID) + " From " + Convert.ToDateTime(rdpcStartDate.SelectedDate).ToString("dd MMM yyyy") + " To " + Convert.ToDateTime(rdpcEndDate.SelectedDate).ToString("dd MMM yyyy");
                    Mmsg.IsBodyHtml = true;
                    Attachment at = new Attachment(FileNamePath);
                    at.Name = at.Name.Substring(1, at.Name.Length - 1).Replace('/', ' ');
                    Mmsg.Attachments.Add(at);
  
  
                    NetworkCredential cred = new NetworkCredential("donotreply@impetusconsulting.net", "donotreply");
                    //SmtpClient mailClient = new SmtpClient("impetusconsulting.net");
                    SmtpClient mailClient = new SmtpClient("impetusconsulting.net");
                    //AuthenHost
                    mailClient.Credentials = cred;
                    try
                    {
                        mailClient.Send(Mmsg);
                        Mmsg.Attachments.Dispose();
                        Mmsg.Dispose();
                    }
                    catch (Exception ee)
                    {
                    }
                    finally
                    {
                        FileInfo fi = new FileInfo(FileNamePath);
                        if (fi != null && fi.Exists)
                        {
                            try
                            {
                                fi.Refresh();
                                System.IO.File.Delete(FileNamePath);
                                //File.Delete(FileNamePath);
                                //fi.Delete();
                            }
                            catch (Exception ex)
                            {
  
                            }
                        }
                    }
  
                    Mail = false;
                    Response.Redirect("~/Timesheets/TimesheetByProject.aspx");
                }
                catch (ExecutionEngineException ex)
                {
                    Mail = false;
                }
                finally
                {
                    Mail = false;
                }
            }
  
        }
        //For Alert while mail sent 
  
        protected void ExportToMail_Click(object sender, EventArgs e)
        {
            if ((CompanyEmail == "") || (Email == ""))
            {
                openRadWindow(rwmTemp, "DesignRAD.aspx?i=1", "Alert", 390, 160);
            }
            else
            {
                Mail = true;
                openRadWindow(rwmTemp, "DesignRAD.aspx?i=0", "Alert", 390, 160);
            }
        }
  
        public void openRadWindow(RadWindowManager rwmTemp, String FileName, String WindowTitle, Int32 Width, Int32 Height)
        {
            RadWindow newWindow = new RadWindow();
            newWindow.NavigateUrl = FileName;
            newWindow.Title = WindowTitle;
            newWindow.VisibleOnPageLoad = true;
            newWindow.Width = Width;
            newWindow.OnClientClose = "CloseWindow1";
            newWindow.Height = Height;
            rwmTemp.Windows.Add(newWindow);
        }
  
        protected void ManualExportToMail(object sender, EventArgs e)
        {
            if (ConfigureExport())
            {
                //Mail = true;
                dataLayer dl = new dataLayer();
                rgvReport.ExportSettings.FileName = "Timesheet By Project Report for " + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID);
                rgvReport.ExportSettings.Pdf.PageTitle = "Timesheet By Project Report for " + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID);
                rgvReport.ExportSettings.IgnorePaging = true;
                rgvReport.MasterTableView.ExportToPdf();
            }
        }
  
  
        ///*
        // * Modified By Leo and Anto
        // * Method Used to Send Mail with PDF Attachment.
        // * Set Mail as true
        // * This will invoke the above method ie rgvReport_GridExporting()
        // */
        //protected void ExportToMail_Click(object sender, EventArgs e)
        //{
        //    if (ConfigureExport())
        //    {
        //        Mail = true;
        //        dataLayer dl = new dataLayer();
        //        rgvReport.ExportSettings.FileName = "Timesheet By Project Report for " + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID);
        //        rgvReport.ExportSettings.Pdf.PageTitle = "Timesheet By Project Report for " + dl.getUserNameByID(((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID);
        //        rgvReport.ExportSettings.IgnorePaging = true;
        //        rgvReport.MasterTableView.ExportToPdf();
        //    }
        //}
  
    }
}

 

 

- Anto

0
Vasil
Telerik team
answered on 28 Mar 2011, 04:04 PM
Hi Anto,

I examined your source code. However because of missing data classes I was not able to debug it directly. So I simplified the RadGrid's declaration and changed NeedDataSource event handler to be able to run the project. Here the grid is showing fine in both IE and Chrome. Please see the attached screenshots and the modified version of your code and let me know what I missed.

All the best,
Vasil
the Telerik team
Tags
Grid
Asked by
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Answers by
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Vasil
Telerik team
Share this question
or