Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
88 views
Hi All ,
   1.      I have two detail Tables in my RadGrid . when I am exporting it in excel the bad image of paging icons are also getting                   exported in excel. 
  2.   with this code when I am exporting the excel file  records are hidden by default (have records but rows are not visible by default we have to increase the row height every  time to see  the records) please see  the attached image 

        these bad images are exporting only for those child grids which have data in it.  please let me know what I am doing wrong.  my code behind code is

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/.master" AutoEventWireup="true"
    CodeFile="Sample.aspx.cs" Inherits="Sample" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_Content" runat="Server">
    <script type="text/javascript">

        
        //To refresh domains and roles grid
        function RefreshSampleRadGrid() {
            var radMgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>');
            radMgr.ajaxRequest("SampleRadGrid");
            return false;
        }
        
        function DisableAjax(eventTarget, eventArgument) {

            $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>').__doPostBack(eventTarget, eventArgument);
        }
    </script>
    <telerik:RadSplitter ID="SampleRadSplitter" runat="server">
        <telerik:RadPane ID="TopRadPane" runat="server" SkinID="TopRadPane">
        </telerik:RadPane>
        <telerik:RadSplitBar ID="ProfileRadSplitBar" runat="server" />
        <telerik:RadPane ID="SampleRadPane" runat="server" SkinID="BottomRadPane">
            <telerik:RadDockLayout ID="SampleRadDockLayout" runat="server" OnLoadDockLayout="SampleRadDockLayout_LoadDockLayout">
                <asp:Label ID="MessageLabel" runat="server" Visible="false" SkinID="MessageLabel"></asp:Label>
                <telerik:RadDockZone BorderStyle="None" ID="SampleRadDockZone" runat="server">
                    <telerik:RadDock ID="SampleRadDock" runat="server" OnCommand="RadDock_Command">
                        <TitlebarTemplate>
                            <table class="RadDockTitlebarTemplateTableClass">
                                <tr>
                                    <td>
                                        <asp:Label ID="ConfigurationFileLabel" runat="server" Text="Configuration File"
                                            SkinID="RadDockTitleLabel" />
                                    </td>
                                    <td>
                                        <asp:LinkButton ID="RemoveLinkButton" runat="server" Text="Clear Selected" SkinID="SmallLinkButton"
                                            OnClick="RemoveLinkButton_Click"></asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </TitlebarTemplate>
                        <ContentTemplate>
                            <div class="RadGridHorizontalScroll">
                                <telerik:RadGrid ID="SampleRadGrid" OnPreRender="SampleRadGrid_PreRender" OnNeedDataSource="SampleRadGrid_NeedDataSource"
                                    runat="server" Width="99.4%" OnDetailTableDataBind="SampleRadGrid_DetailTableDataBind"
                                    OnItemDataBound="SampleRadGrid_ItemDataBound" OnItemCreated="SampleRadGrid_ItemCreated"
                                    OnPageIndexChanged="SampleRadGrid_PageIndexChanged">
                                    <ClientSettings>
                                        <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true"
                                            ClipCellContentOnResize="true" />
                                    </ClientSettings>
                                    <MasterTableView DataKeyNames="userID,userName" HierarchyLoadMode="Client"
                                        HierarchyDefaultExpanded="false" TableLayout="Fixed" CommandItemDisplay="Top">
                                        <CommandItemTemplate>
                                            <table width="100%">
                                                <tr>
                                                    <td></td>
                                                    <td class="ExportButtonIconSaperator">
                                                        <asp:ImageButton ID="ExportToExcelImageButton" SkinID="ExportToExcelImageButtonSkin"
                                                            runat="server" OnClick="ExportToExcelImageButton_Click" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </CommandItemTemplate>

                                        <Columns>
                                            <telerik:GridBoundColumn SortExpression="userName" HeaderText="user" HeaderButtonType="TextButton"
                                                DataField="userName">
                                                <%-- Defect# 12711--%>
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                        <DetailTables>
                                            <telerik:GridTableView DataKeyNames="ConfigurationID,userID" GridLines="None" HierarchyLoadMode="Client" HierarchyDefaultExpanded="true">
                                                <PagerStyle Visible="false" />
                                                <ParentTableRelation>
                                                    <telerik:GridRelationFields DetailKeyField="userID" MasterKeyField="userID" />
                                                </ParentTableRelation>
                                                <Columns>
                                                    <telerik:GridBoundColumn DataField="ConfigurationDesc" HeaderText="Configuration Name"
                                                        UniqueName="ConfigurationDesc">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="user" HeaderText="user" UniqueName="user">
                                                        <%-- Defect# 12711--%>
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="FixedColumn" HeaderText="Fixed Column" UniqueName="FixedColumn">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="meter" HeaderText="meter" UniqueName="meter">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="Type" HeaderText="Code"
                                                        UniqueName="DisbursementType">
                                                    </telerik:GridBoundColumn>
                                                </Columns>
                                                <DetailTables>
                                                    <telerik:GridTableView DataKeyNames="ID,userID" Width="100%" GridLines="None"
                                                        HierarchyLoadMode="Client" AllowCustomPaging="true">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="userID" MasterKeyField="userID" />
                                                        </ParentTableRelation>
                                                        <Columns>
                                                            <telerik:GridTemplateColumn UniqueName="SelectItemCheckBoxColumn" Resizable="false" Reorderable="false">
                                                                <ItemTemplate>
                                                                    <asp:CheckBox ID="SelectItemCheckBox" runat="server" onclick="return CheckItem(this);" />
                                                                </ItemTemplate>
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox ID="SelectHeaderCheckBox" runat="server" onclick="CheckAll(this);" />
                                                                </HeaderTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridTemplateColumn HeaderText="Action" UniqueName="TemplateColumn" Resizable="false" Reorderable="false">
                                                                <ItemTemplate>
                                                                    <asp:HyperLink ID="EditHyperLink" runat="server" Text="Edit" SkinID="SmallHyperLink"></asp:HyperLink>
                                                                </ItemTemplate>
                                                                <HeaderStyle Width="5%" />
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridBoundColumn DataField="UniqueNumber" HeaderText="Unique Number"
                                                                UniqueName="UniqueNumber" SortExpression="UniqueNumber">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Number" HeaderText="Number" UniqueName="Number"
                                                                SortExpression="Number">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="com" HeaderText="com" UniqueName="com"
                                                                SortExpression="com">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Date/Time" HeaderText="Date/Time" UniqueName="Date/Time"
                                                                SortExpression="Date/Time">
                                                                <HeaderStyle Width="10%" />
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="com" HeaderText=" com" UniqueName="com" SortExpression="com">
                                                                <%-- Defect# 12711--%>
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Pump" HeaderText=" Dispenser" UniqueName="Pump" SortExpression="Pump">
                                                                <%-- Defect# 12711--%>
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Type" HeaderText=" Type" UniqueName="Type"
                                                                SortExpression="Type">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Quantity" HeaderText="Quantity" UniqueName="Quantity"
                                                                SortExpression="Quantity">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn DataField="Cost" HeaderText="Cost" UniqueName="Cost" SortExpression="Cost">
                                                            <telerik:GridBoundColumn DataField="ErrorDescription" HeaderText="Error Description"
                                                                UniqueName="ErrorDescription" SortExpression="ErrorDescription">
                                                                <HeaderStyle Width="20%" />
                                                            </telerik:GridBoundColumn>
                                                        </Columns>
                                                    </telerik:GridTableView>
                                                </DetailTables>
                                            </telerik:GridTableView>
                                        </DetailTables>
                                    </MasterTableView>
                                </telerik:RadGrid>
                            </div>
                        </ContentTemplate>
                        <Commands>
                            <telerik:DockCommand Text="Save Position" AutoPostBack="true" />
                            <telerik:DockExpandCollapseCommand />
                        </Commands>
                    </telerik:RadDock>
                </telerik:RadDockZone>
            </telerik:RadDockLayout>
            <telerik:RadWindowManager ID="RadWindowManager" runat="server">
                <Windows>
                    <telerik:RadWindow ID="EditDialog" Title=" Transactions"
                        Left="150px" runat="server" />
                    <telerik:RadWindow ID="ErrorDialog" Title="Process Errors" Left="150px" runat="server"></telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        </telerik:RadPane>
    </telerik:RadSplitter>
</asp:Content>





public partial class Sample 
{
   #region Events

    protected void Page_Load(object sender, EventArgs e)
    {
        TitleSetHelper.Instance.SetHeaderText(sampleRadGrid);
        ValidateCredentials(FuelPermission.Check(SecurityAttribute.FuelPerm.FuelTransactionImport), false);
        RadAjaxManager radAjaxManager = Master.FindControl("RadAjaxManagerFuel") as RadAjaxManager;
        if (radAjaxManager != null)
        {
            radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, sampleRadGrid);
            radAjaxManager.AjaxSettings.AddAjaxSetting(sampleRadGrid, sampleRadGrid);
            radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, RemoveLinkButton);
            radAjaxManager.AjaxSettings.AddAjaxSetting(sampleRadGrid, RemoveLinkButton);
            radAjaxManager.AjaxSettings.AddAjaxSetting(sampleRadGrid, MessageLabel);
            radAjaxManager.AjaxSettings.AddAjaxSetting(RemoveLinkButton, MessageLabel);
        }
        
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        AddCustomPager(sampleRadGrid);
        GridTableView gridTableView = sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0];
        if (gridTableView != null)
        {
            gridTableView.AllowPaging = true;
            gridTableView.PagerStyle.AlwaysVisible = true;
        }
       
    }


    protected void sampleRadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        try
        {
            userInfoList userInfoList = userInfoList.GetInfoList("user", (Int32)userStatus.Active);
            DataTable dataTable = new DataTable("userInfoListData");
            dataTable.Columns.Add(new DataColumn("userID", Type.GetType("System.Int32")));
            dataTable.Columns.Add(new DataColumn("userName", Type.GetType("System.String")));

            foreach (userInfo userInfo in userInfoList)
            {
                DataRow dataRow = dataTable.NewRow();
                dataRow["userID"] = userInfo.userID;
                dataRow["userName"] = userInfo.userName;
                dataTable.Rows.Add(dataRow);
            }
            sampleRadGrid.DataSource = dataTable;
        }
        catch (Exception ex)
        {
            FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.userInfoListGet, MessageLabel, null);
        }
        if (Cacheobject[String.Format("GridPageIndex{0}", _guid)] != null)
            sampleRadGrid.CurrentPageIndex = (Int32)Cacheobject[String.Format("GridPageIndex{0}", _guid)];
    }

    protected void sampleRadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
       
        
        Cacheobject.Remove(String.Format("IDList{0}", _guid));
        //if (Cacheobject[String.Format("user{0}", _guid)] != null)
        Cacheobject.Remove(String.Format("user{0}", _guid));
        //if (Cacheobject[String.Format("GridPageIndex{0}", _guid)] != null)
        Cacheobject.Remove(String.Format("GridPageIndex{0}", _guid));
        List<Int32> transactionIDList = new List<Int32>();
        Int32 userID = 0;
        Int32 ConfigurationID = 0;
        String userName = String.Empty;
        GridDataItem dataItem = e.DetailTableView.ParentItem;
        userID = Convert.ToInt32(dataItem.GetDataKeyValue("userID"));
        AddCache(String.Format("user{0}", _guid), userID);
        userName = Convert.ToString(dataItem.GetDataKeyValue("userName"));
        ConfigurationID = Convert.ToInt32(dataItem.GetDataKeyValue("ConfigurationID"));
        DataSet dataSet = new DataSet();

        if (ConfigurationID == 0)
        {
            try
            {
                sampleRadGrid.VirtualItemCount = InfoList.GetTotalRecords(userID);
            }
           
            catch (Exception ex)
            {
                ExceptionHandler.Instance.HandleException(ex, ExceptionResources.InfoList, MessageLabel, null, "userID: " + userID);
            }

      

            DataTable dataTable = new DataTable("Configuration");
            dataTable.Columns.Add(new DataColumn("ConfigurationID", System.Type.GetType("System.Int32")));
            dataTable.Columns.Add(new DataColumn("userID", System.Type.GetType("System.Int32")));
            dataTable.Columns.Add(new DataColumn("ConfigurationDesc", System.Type.GetType("System.String")));
            dataTable.Columns.Add(new DataColumn("user", System.Type.GetType("System.String")));
            dataTable.Columns.Add(new DataColumn("FixedColumn", System.Type.GetType("System.String")));
            dataTable.Columns.Add(new DataColumn("meter", System.Type.GetType("System.String")));
            dataTable.Columns.Add(new DataColumn("Type", System.Type.GetType("System.String")));
            ConfigurationInfo ConfigurationInfo = null;
            try
            {
                ConfigurationInfo = ConfigurationInfo.GetInfo(null, userID);
            }
          
            catch (Exception ex)
            {
                FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.ConfigurationInfoGet, MessageLabel, null);
            }

            if (ConfigurationInfo != null)
            {
                DataRow row = dataTable.NewRow();
                row["ConfigurationID"] = ConfigurationInfo.ConfigurationID;
                row["userID"] = ConfigurationInfo.userID;
                row["ConfigurationDesc"] = ConfigurationInfo.ConfigurationDesc;
                row["user"] = userName;
                row["FixedColumn"] = ConfigurationInfo.IsColumnFixed ? "Yes" : "No";
                try
                {
                    row["meter"] = ConfigurationInfo.DelimeterID == null ? String.Empty : STLImportConfigurationDelimeterInfo.GetInfo(Convert.ToInt32(ConfigurationInfo.DelimeterID)).DelimeterDesc;
                }
              
                catch (Exception ex)
                {
                    FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.ImportConfigurationDelimeterGet, MessageLabel, null);
                }
                try
                {
                    row["Type"] = ConfigurationInfo.DisbursementID == null ? String.Empty : STLDisbursementInfo.GetInfo(Convert.ToInt32(ConfigurationInfo.DisbursementID)).DisbursementDesc;
                }
                //Updated by CB for Feature# 2575
                catch (Exception ex)
                {
                    FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.STLDisbursementInfoGet, MessageLabel, null);
                }
                dataTable.Rows.Add(row);
            }
            dataSet.Merge(dataTable);

           
        }
        else
        {
            #region Processing Errors Grid

            DataTable tempDataTable = new DataTable("tempDataTable");
            tempDataTable.Columns.Add(new DataColumn("TransactionID", Type.GetType("System.Int32")));
            tempDataTable.Columns.Add(new DataColumn("userID", Type.GetType("System.Int32")));
            tempDataTable.Columns.Add(new DataColumn("TransactionNumber", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("AssetNumber", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("Organization", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("Date/Time", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("Site", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("Pump", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("FuelType", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("Quantity", Type.GetType("System.String")));
            tempDataTable.Columns.Add(new DataColumn("ErrorDescription", Type.GetType("System.String")));
            //To get sort expression.
            System.Text.StringBuilder sortExpression = new System.Text.StringBuilder();
            foreach (GridSortExpression gridSortExpression in sampleRadGrid.MasterTableView.SortExpressions)
            {
                sortExpression.Append(gridSortExpression.FieldName);
                if (gridSortExpression.SortOrder == GridSortOrder.Descending)
                    sortExpression.Append(" Desc");
                else
                    sortExpression.Append(" Asc");
                sortExpression.Append(",");
            }
            try
            {
                if (Cacheobject[String.Format("DetailTablePageIndex{0}", _guid)] != null && Cacheobject[String.Format("IsPageIndexChanged{0}", _guid)] != null)
                {
                    e.DetailTableView.CurrentPageIndex = (Int32)Cacheobject[String.Format("DetailTablePageIndex{0}", _guid)];
                    Cacheobject.Remove(String.Format("IsPageIndexChanged{0}", _guid));
                }
                if (Cacheobject[String.Format("PageSize{0}", _guid)] != null)
                {
                    e.DetailTableView.PageSize = (Int32)Cacheobject[String.Format("PageSize{0}", _guid)];
                    Cacheobject.Remove(String.Format("PageSize{0}", _guid));
                }
                InfoList InfoList = InfoList.GetInfoList(userID, e.DetailTableView.CurrentPageIndex + 1, e.DetailTableView.PageSize, sortExpression.ToString());
                _pageSize = e.DetailTableView.PageSize;
                _sortExpression = sortExpression.ToString();
                foreach (TempFuelTransactionInfo tempFuelTransaction in InfoList)
                {
                    if (IDList.Count < e.DetailTableView.PageSize)
                    {
                        String site = String.Empty;
                        String pump = String.Empty;
                        String errorDescription = String.Empty;
                        String billCode = String.Empty;
                        DataRow Row = tempDataTable.NewRow();
                        Row["TransactionID"] = temp.ID;
                        Row["userID"] = tempFuelTransaction.userID;
                        Row["TransactionNumber"] = tempFuelTransaction.TransactionNumber;
                        Row["Organization"] = tempFuelTransaction.Organization;
                        if (!String.IsNullOrEmpty(tempFuelTransaction.TransactionDate))
                            Row["Date/Time"] = Convert.ToDateTime(tempFuelTransaction.TransactionDate).ToString("MM/dd/yyyy HH:mm:sss");
                        _transactionID = tempFuelTransaction.TransactionID;
                        Boolean isError = false;
                        String rejectedRecordBits = tempFuelTransaction.RejectedRecordsBitsString;

                 IDList.Add(tempFuelTransaction.TransactionID);
                }
                AddSlidingCache(String.Format("IDList{0}", _guid), transactionIDList);
                AddSlidingCache(String.Format("GridPageIndex{0}", _guid), sampleRadGrid.CurrentPageIndex);
                AddSlidingCache(String.Format("DetailTablePageIndex{0}", _guid), e.DetailTableView.CurrentPageIndex);
            }
            
            catch (Exception ex)
            {
                FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.TempFuelTransactionInfoGet, MessageLabel, null);
            }
            dataSet.Merge(tempDataTable);

            #endregion
        }
        e.DetailTableView.DataSource = dataSet;
    }

    protected void sampleRadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            HyperLink editHyperLink = e.Item.FindControl("EditHyperLink") as HyperLink;
            if (editHyperLink != null)
            {
                GridDataItem dataItem = e.Item as GridDataItem;
                string checkSite = dataItem["Site"].Text;
                //String formatting off of data item
                //<Font color=red></font>
                if (checkSite.Contains(@"<Font color=red>"))
                    checkSite = checkSite.Replace(@"<Font color=red>", "");
                if (checkSite.Contains(@"</Font>"))
                    checkSite = checkSite.Replace(@"</Font>", "");
                if (checkSite.Contains(_errorImagePath))
                    checkSite = checkSite.Replace(_errorImagePath, "");

               
            }
        }
    }
    protected void sampleRadGrid_PreRender(object sender, EventArgs e)
    {
        Boolean hasRecords = false;
        if (sampleRadGrid.MasterTableView.Items.Count > 0)
        {
            foreach (GridDataItem dataItem in sampleRadGrid.MasterTableView.Items)
            {

                foreach (GridDataItem nestedDataItem in dataItem.ChildItem.NestedTableViews[0].Items)
                {

                    if (!hasRecords && nestedDataItem.ChildItem.NestedTableViews[0].Items.Count > 0)
                    {
                        hasRecords = true;
                        break;
                    }
                }
                if (hasRecords)
                    break;

            }
        }
        RemoveLinkButton.Enabled = hasRecords;
        
    }

    protected void RemoveLinkButton_Click(object sender, EventArgs e)
    {
        String cacheName = String.Format("TempTransactionID{0}", _guid);
        if (Cacheobject[cacheName] != null)
        {
            Cacheobject.Remove(cacheName);
        }
        MessageLabel.Visible = false;
        List<Int32> transactionIDList = new List<Int32>();
        foreach (GridDataItem gridDataItem in sampleRadGrid.Items)
        {
            CheckBox processErrorcheckBox = gridDataItem.FindControl("SelectItemCheckBox") as CheckBox;
            if (processErrorcheckBox != null && processErrorcheckBox.Checked)
            {
                Int32 ID = 0;
                Int32.TryParse(Convert.ToString(gridDataItem.GetDataKeyValue("ID")), out ID);
                transactionIDList.Add(ID);
            }
        }
       
       
    }
    protected void ExportToExcelImageButton_Click(object sender, EventArgs e)
    {
        ExportDataToFile();
        ExportToExcel(sampleRadGrid, "sampleResults", false, String.Empty);
    }
    protected void Page_PreRender(object sender, System.EventArgs e)
    {
        GridItem commandItem = sampleRadGrid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
        ImageButton exportToExcelImageButton = commandItem.FindControl("ExportToExcelImageButton") as ImageButton;
        Boolean isGridHasData = sampleRadGrid.Items.Count > 0;
        if (exportToExcelImageButton != null)
        {
            exportToExcelImageButton.Enabled = isGridHasData;
            if (exportToExcelImageButton.Enabled)
            {
                exportToExcelImageButton.Attributes.Add("onclick", String.Format("DisableAjax(\"{0}\", \"\"); return false;", exportToExcelImageButton.UniqueID));
                exportToExcelImageButton.Style.Add(StringResources.CssCursorKey, StringResources.CssCursorValue);
            }
        }
    }
    private userFuelSiteInfo userFuelSiteGet(string checkSite, int userID)
    {
        userFuelSiteInfo userFuelSiteInfo = null;

        try
        {
            userFuelSiteInfo = userFuelSiteInfo.GetInfo(checkSite, userID);
        }
        //Updated by CB for Feature# 2575
        catch (Exception ex)
        {
            FasterExceptionHandler.Instance.HandleException(ex, ExceptionResources.userFuelSiteInfoGet, MessageLabel, null, "userID:" + userID.ToString() + "userFuelSite:" + checkSite);
        }
        return userFuelSiteInfo;
    }

    protected void sampleRadGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            if (Cacheobject[String.Format("user{0}", _guid)] != null && e.Item.OwnerTableView.HierarchyDefaultExpanded)
            {
                if (Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["userID"]) == (Int32)Cacheobject[String.Format("user{0}", _guid)])
                    e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
                else
                    e.Item.OwnerTableView.HierarchyDefaultExpanded = false;
            }
        }
    }

    protected void sampleRadGrid_PageIndexChanged(object source, GridPageChangedEventArgs e)
    {
        e.Item.OwnerTableView.CurrentPageIndex = e.NewPageIndex;
        AddSlidingCache(String.Format("GridPageIndex{0}", _guid), sampleRadGrid.CurrentPageIndex);
        Cacheobject.Remove(String.Format("DetailTablePageIndex{0}", _guid));
    }

    #endregion

    #region Class Functions
    /// <summary>
    /// Create Export Data
    /// </summary>
    private void ExportDataToFile()
    {
        sampleRadGrid.MasterTableView.ExpandCollapseColumn.Display = false;
        sampleRadGrid.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
        sampleRadGrid.MasterTableView.DetailTables[0].ExpandCollapseColumn.Display = false;
        sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].ExpandCollapseColumn.Display = false;
        sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].ShowFooter  = false;
        sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].ShowGroupFooter= false;
        sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].PagerStyle.Visible  = false;
        sampleRadGrid.ExportSettings.IgnorePaging = true;
        sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].AllowPaging = false;
        GridTemplateColumn templateColumn = sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].Columns.FindByUniqueName("TemplateColumn") as GridTemplateColumn;
        if (templateColumn != null)
            templateColumn.Visible = false;
        GridTemplateColumn selectItemCheckBoxColumn = sampleRadGrid.MasterTableView.DetailTables[0].DetailTables[0].Columns.FindByUniqueName("SelectItemCheckBoxColumn") as GridTemplateColumn;
        if (selectItemCheckBoxColumn != null)
            selectItemCheckBoxColumn.Visible = false;
    }
    protected void ExportToExcel(RadGrid searchRadGrid, String fileName, Boolean isActionColumn, String columnUniqueName)
        {
            if (isActionColumn)
                searchRadGrid.MasterTableView.Columns.FindByUniqueName(columnUniqueName).Display = false;
            
            if (searchRadGrid.MasterTableView.HasDetailTables)
            {
                foreach (GridTableView gridTableView in searchRadGrid.MasterTableView.DetailTables)
                {
                    // Added by partner CB to Fix defect 15597 
                    gridTableView.AllowPaging = false;
                    gridTableView.HierarchyDefaultExpanded = true;
                }
            }
            searchRadGrid.ExcelExportCellFormatting += new OnExcelExportCellFormattingEventHandler(SearchRadGrid_ExcelExportCellFormatting);
            searchRadGrid.ItemCreated += new GridItemEventHandler(RadGrid_ItemCreated);
            searchRadGrid.ExportSettings.ExportOnlyData = true;
            searchRadGrid.ExportSettings.IgnorePaging = true;
            searchRadGrid.ExportSettings.OpenInNewWindow = true;
            searchRadGrid.ExportSettings.FileName = fileName;
            _isExport = true;
            searchRadGrid.MasterTableView.ExportToExcel();
        }
    #endregion
}
Shubham
Top achievements
Rank 1
 asked on 12 Feb 2014
4 answers
160 views
I am using the drag and drop feature on the grid to swap rows.  The challenage is the dotted line that shows above or below the drop row is confusing to users.   Is their a weay to hide the dotted line above or below an item that's being dragged too?

Thanks,
Todd.
Konstantin Dikov
Telerik team
 answered on 12 Feb 2014
32 answers
1.6K+ views
I have the following radnumerictextbox which is behaving oddly

<telerik:RadNumericTextBox ID="txtAmount" runat="server" TabIndex="23" MaxLength="15" 
     DataType="System.Decimal" Width="50px" AllowOutOfRangeAutoCorrect="False" MaxValue="922337203685477" 
     Type="Currency" EmptyMessage="$" style="text-align:right" EnabledStyle-HorizontalAlign="Right"  /> 
 

When the page first loads, the textbox is aligned to the left.  As soon as the mouse enters it, it becomes aligned to the right.  How can I make it align to the right when the page first loads?



Princy
Top achievements
Rank 2
 answered on 12 Feb 2014
2 answers
60 views
I have a problem with RadAjaxLoadingPanel. I'm not able to use it the right way. There is a sample of my code here. LoadingPanel starts work after I'll change skin with SkinManager dropdown. Could anybody help me and tell me what I have to do to make it work without this trick?

My page:

<form id="form1" runat="server">
       <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
       <telerik:RadSkinManager ID="SkinManager1" runat="server" ShowChooser="true" />
       <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="Panel1">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>
       <div>
           <asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center" Height="275px" Style="padding-top: 15px; padding-left: 15px">
               <asp:Button ID="Button1" runat="server" Text="Click to see the loading image" OnClick="Button1_Click"></asp:Button>
               treatretae
           </asp:Panel>
       </div>
       <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
       </telerik:RadAjaxLoadingPanel>
   </form>


Code behind:
namespace TelerikWebApp1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public void Button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(2000);
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
    }
}


Thanks for any help.
KTK
Top achievements
Rank 1
 answered on 12 Feb 2014
20 answers
191 views
We have an app that uses RadAsyncUpload.

If Silverlight isn't installed at all, the the control fails over to the next control type (flash?) before going back to the old school way of doing things.

This is all fine.

If, on the other hand, the user does have Silverlight installed, but it is some version other than Silverlight 5 then the control complains that the wrong version is installed and does nothing.

Now, in the ideal world the user would just update their version of Silverlight and all would be well with the world. Sadly, the users in question are run by IT departments that are only just coming to terms with the fact that there are browsers other than IE6, so upgrading anything is simply a non-starter.

Is there something we can do that will:
  1. use the installed version of Silverlight, where that version is correct (Silverlight 5 only, I assume)
  2. failover to the next available Async upload method where Silverlight is not installed or it is installed but is the wrong version.

I know that I can force the system to believe that Silverlight isn't installed, but I don't want to penalize those users whose IT departments are enlightened enough to have the most recent version installed.

--
Stuart

Peter Filipov
Telerik team
 answered on 12 Feb 2014
4 answers
238 views

Hi

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestPartialPostback.aspx.vb"
    Inherits="Rentware.TestPartialPostback" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
        <br />
        <telerik:RadFormDecorator ID="rfDecorator" runat="server" DecoratedControls="Buttons,Fieldset,RadioButtons,CheckBoxes" />
        <telerik:RadWindowManager runat="server" ID="radWindowMgr" />
        <telerik:RadAjaxManager ID="radAjaxMgr" runat="server">
            <ajaxsettings>
            <telerik:AjaxSetting AjaxControlID="cbTest">
                <UpdatedControls>                    
                    <telerik:AjaxUpdatedControl ControlID="testPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            </ajaxsettings>
        </telerik:RadAjaxManager>
        <h2>
            Account Management</h2>
        <telerik:RadTabStrip ID="RadTabsAccManage" runat="server" MultiPageID="RadMultiPageAccManage"
            SelectedIndex="0" Skin="WebBlue">
            <tabs>
            <telerik:RadTab Text="General">
            </telerik:RadTab>
            <telerik:RadTab Text="Contacts">
            </telerik:RadTab>
        </tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPageAccManage" runat="server" SelectedIndex="0">
            <telerik:RadPageView ID="RadPageViewAccManageGeneral" runat="server">
                <telerik:RadGrid ID="RadGridAccManageMain" runat="server" GridLines="None" AutoGenerateColumns="False"
                    ShowStatusBar="true" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                    AllowAutomaticUpdates="True" DataSourceID="SqlDataSource1">
                    <alternatingitemstyle cssclass="DisplayNone" />
                    <itemstyle cssclass="DisplayNone" />
                    <headerstyle cssclass="DisplayNone" />
                    <footerstyle cssclass="DisplayNone" />
                    <groupingsettings casesensitive="false" />
                    <mastertableview gridlines="None" datasourceid="SqlDataSource1" autogeneratecolumns="false"
                        datakeynames="RegionID">
                    <Columns>
                        <telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Center" AllowFiltering="false">
                            <ItemTemplate>
                                   
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <EditFormSettings EditFormType="Template">
                        <FormTemplate>
                            <asp:CheckBox ID="cbTest" runat="server" Text="Enable" TextAlign="Left"
                                OnCheckedChanged="checkBoxCheckedChanaged" AutoPostBack="true" />
                            <asp:Panel ID="testPanel" runat="server" Enabled="false">
                                <fieldset>
                                    <legend>Add Or Edit Region:</legend>Region Description:
                                    <asp:TextBox runat="server" ID="txtText" Text='<%#Bind("RegionDescription") %>' />
                                </fieldset></asp:Panel>
                        </FormTemplate>
                    </EditFormSettings>
                </mastertableview>
                </telerik:RadGrid>
                <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RegionID], [RegionDescription] FROM [Region] WHERE ([RegionID] = @RegionID)"
                    runat="server">
                    <SelectParameters>
                        <asp:SessionParameter Name="RegionID" SessionField="regionId" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageViewAccManageContacts" runat="server">
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    </div>
    </form>
</body>
</html>
Imports Telerik.Web.UI
Partial Public Class TestPartialPostback
    Inherits System.Web.UI.Page
    Dim regionId As Integer
    Dim commandName As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            regionId = Convert.ToInt32(Convert.ToString(Request.QueryString("regionId")))
            Session("regionId") = regionId
        End If
        commandName = IIf(Session("regionId").Equals(0), "PerformInsert", "Update").ToString()
    End Sub
    Private Sub RadGridAccManageMain_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridAccManageMain.ItemCreated
        If TypeOf e.Item Is GridEditableItem AndAlso commandName = "Update" Then
            e.Item.Edit = True
        End If
    End Sub
  
    Protected Sub RadGridAccManageMain_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGridAccManageMain.PreRender
        If Not Page.IsPostBack And commandName = "PerformInsert" Then
            RadGridAccManageMain.MasterTableView.IsItemInserted = True
            RadGridAccManageMain.Rebind()
            'RadGridAccManageMain.MasterTableView.InsertItem()
            RadGridAccManageMain.HeaderStyle.CssClass = "rgEditRow"
        End If
    End Sub
    Protected Sub checkBoxCheckedChanaged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim thisCheckBox As CheckBox = CType(sender, CheckBox)
        Dim editItem As GridEditFormItem = DirectCast(thisCheckBox.NamingContainer, GridEditFormItem)
  
        CType(editItem.FindControl("testPanel"), Panel).Enabled = thisCheckBox.Checked
    End Sub
End Class

I’m using RadGrid for editing and inserting row in the place of using asp.net form view.  I’m passing the parameter to select the row for editing through query string.I’m assigning that query string to session variable in page load event and that session variable serves as select parameter in SQL Data source.If I get the required query string I’m putting RadGrid in Item Edit Mode and if not It will open the RadGrid in Item Insert mode.Inside Form Template I’ve a checkbox and asp.net panel that wraps all other contents of Form Template. I have an event to handle check box checked status changed.In that event I’m enabling and disabling the panel based on if the checkbox is checked or not.

 

I’ve RadAjaxManager in place with Ajax settings.  I’ve an AJAX setting in that RadAjaxManager with AjaxControlID as ID of the checkbox and AJAX updated control ID as the ID of the panel. So If I check or uncheck the checkbox In either Edit Mode or Insert Mode the panel should be enabled or disabled through AJAX partial post back.

 

Problem/Bug:

If the page loaded in insert mode for the first time and if I check the checkbox it is doing full post back and I can observe that clearly. (This is not expected behaviour).If I check the checkbox again it is doing partial ajaxified post back.But In Edit mode it is working fine (doing partial ajaxified post back) at all time.How I can fix this issue. For your reference I’ve attached the aspx and code behind file for you. It is stopping us from progressing further; your help would be very much appreciated.

Maria Ilieva
Telerik team
 answered on 12 Feb 2014
7 answers
570 views
I have a grid with an attachment column and every time I download an image, the Rad Grid status bar loading image just sits there a spins. Is there a way to hide or better yet, control the loading image?  

Please note, I am NOT referring to a RadAjaxLoadingPanel loading image, I know how to manage that...I am referring to the little spinner in the lower left hand side of the grid that is visible on post back.


Maria Ilieva
Telerik team
 answered on 12 Feb 2014
2 answers
99 views
I've been running Telerik tools and extensions with VS studio for about a year.  I am now upgrading to VS 2012.  What do I need to do to get the extensions with my VS 2012?  We are running on Telerik 2013.2.717.35. 

Thanks
Hunter
Missing User
 answered on 12 Feb 2014
1 answer
300 views
Hi,

Don't hold me to this, but this "may" have started after our recent upgrade to 2013.3.1324.45.

When I enter text and hit the Enter/Return key I get the expected appearance in the Design view, like this:

First line
Second line
Third line

When I subsequently save the record and reopen it, I see:

First lineCHAR(13) + CHAR(10) Second lineCHAR(13) + CHAR(10) Third line

in all 3 modes (Design, HTML and Preview).

Here's the RadEditor declaration.  By the way, we have made some minor changes to the Vista skin, but the problem persists even if I change EnableEmbeddedSkins to "true".

<telerik:RadEditor EnableEmbeddedSkins="false" Skin="Vista" ID="edtAnsRichText" runat="server"<br>                                                    Content='<%# Bind("AnswerText") %>' Width="450px" Height="200px" ToolTip="This is what the user will actually see when they take the questionnaire"><br>                                                    <Tools><br>                                                <telerik:EditorToolGroup Tag="MainToolbar"><br>                                                    <telerik:EditorSplitButton Name="Undo"><br>                                                    </telerik:EditorSplitButton><br>                                                    <telerik:EditorSplitButton Name="Redo"><br>                                                    </telerik:EditorSplitButton><br>                                                    <telerik:EditorSeparator /><br>                                                    <telerik:EditorTool Name="Cut" /><br>                                                    <telerik:EditorTool Name="Copy" /><br>                                                    <telerik:EditorTool Name="Paste" ShortCut="CTRL+V" /><br>                                                    <telerik:EditorTool Name="FormatStripper" /><br>                                                    <telerik:EditorTool Name="PasteStrip" /><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="Formatting"><br>                                                    <telerik:EditorTool Name="Bold" /><br>                                                    <telerik:EditorTool Name="Italic" /><br>                                                    <telerik:EditorTool Name="Underline" /><br>                                                    <telerik:EditorSeparator /><br>                                                    <telerik:EditorSplitButton Name="ForeColor"><br>                                                    </telerik:EditorSplitButton><br>                                                    <telerik:EditorSplitButton Name="BackColor"><br>                                                    </telerik:EditorSplitButton><br>                                                    <telerik:EditorSeparator /><br>                                                    <telerik:EditorDropDown Name="FontName"><br>                                                    </telerik:EditorDropDown><br>                                                    <telerik:EditorDropDown Name="FontSize"><br>                                                    </telerik:EditorDropDown><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="Alignment"><br>                                                    <telerik:EditorTool Name="Indent" /><br>                                                    <telerik:EditorTool Name="Outdent" /><br>                                                    <telerik:EditorTool Name="JustifyLeft" /><br>                                                    <telerik:EditorTool Name="JustifyCenter" /><br>                                                    <telerik:EditorTool Name="JustifyRight" /><br>                                                    <telerik:EditorTool Name="JustifyFull" /><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="Tables"><br>                                                    <telerik:EditorTool Name="InsertTable" /><br>                                                    <telerik:EditorTool Name="ToggleTableBorder" /><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="Lists"><br>                                                    <telerik:EditorTool Name="InsertUnorderedList" /><br>                                                    <telerik:EditorTool Name="InsertOrderedList" /><br>                                                    <telerik:EditorTool Name="InsertHorizontalRule" /><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="ImagesAndLinks"><br>                                                    <telerik:EditorSeparator /><br>                                                    <telerik:EditorTool Name="InsertLink" /><br>                                                    <telerik:EditorTool Name="Unlink" /><br>                                                </telerik:EditorToolGroup><br>                                                <telerik:EditorToolGroup Tag="Spell"><br>                                                    <telerik:EditorTool Name="AjaxSpellCheck" /><br>                                                </telerik:EditorToolGroup><br>                                            </Tools><br>                                                </telerik:RadEditor>

Any suggestions on how to debug/resolve this issue?

Thanks in advance.

Jim
Ianko
Telerik team
 answered on 12 Feb 2014
1 answer
89 views
Hi there.

I have a pivot grid showing monthly figures. I also give the user the option to change this to quarterly or annually (updates the GroupInterval attribute).

I need to show % change between months and also between quarters and years when they change the GroupInterval to these intervals.

I was thinking to create a custom sub total to display these % changes. Would that be the best solution? How would I do that?

Thanks.
Antonio Stoilkov
Telerik team
 answered on 12 Feb 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?