Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
100 views

Hello,

I try to export RadGrid using the following code.

 

static GridItemType[] supportedItemTypes = new GridItemType[] {
            GridItemType.GroupHeader,
            GridItemType.Header,
            GridItemType.AlternatingItem,
            GridItemType.Item,
            GridItemType.Footer,
            GridItemType.GroupFooter
        };
       
        private void AddGrid(Worksheet pWS,pssRadGrid pGrid) {
        
            foreach (GridItem item in pGrid.MasterTableView.GetItems(supportedItemTypes))
                etc....

within the foreach loop i get the items in that order:

header
footer
item
item
etc.

 

Is there a way to get the items in the right order for exporting

 

header
item
item
.
.
.
footer

Thanks in advance

 

Daniel
Telerik team
 answered on 09 Jul 2015
1 answer
100 views

Hello,

 

First i don't know if this is the correct place to post or i should have posted in the HTMLChart section,

 

Anyways I'm binding RadHTML Chart to a PivotGrid and everything is working perfectly excepts that the series names of the htmlchart are in an incorrect order, for example:

 

If i have the below pivot:

 

   Name   :   Col1   |    Col2   |   Col3   |   Col4   

   A          :      1      |      4      |      5     |      2

   B          :      7      |      3      |      2     |      1

   C          :      5      |      1      |      4     |      2

 

I get it in the HTML Chart as follows:

 

X Axis name of Col3 with Series and Y value of Col2 and so on for the rest

------------------------------------------------------------------------------------------------------------------

The ASP code is:

 

<telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" DataSourceID="SqlDataSource1" OnCellDataBound="RadPivotGrid1_CellDataBound">
                                    <Fields>
                                        <telerik:PivotGridColumnField UniqueName="column" DataField="ProjectName" Caption="Project"></telerik:PivotGridColumnField>
                                        <telerik:PivotGridRowField UniqueName="column1" DataField="DisplayName" Caption="Name"></telerik:PivotGridRowField>
                                        <telerik:PivotGridAggregateField GrandTotalAggregateFormatString="" CalculationExpression="" UniqueName="column2" DataField="Duration" Caption="Duration">
                                            <TotalFormat Level="0" Axis="Rows" TotalFunction="NoCalculation" SortOrder="Ascending"></TotalFormat>
                                        </telerik:PivotGridAggregateField>
                                    </Fields>
 
                                    <ConfigurationPanelSettings DefaultDeferedLayoutUpdate="True"></ConfigurationPanelSettings>
                                </telerik:RadPivotGrid>
                                <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" DataSourceID="SqlDataSource1">
                                    <Legend>
                                        <Appearance Position="Bottom">
                                        </Appearance>
                                    </Legend>
                                </telerik:RadHtmlChart>

I have SQLDataSource which is populated from Code behind, The code behind as follows:

    Private columnNames As New HashSet(Of String)()
    Private columnSeriesByRowName As New Dictionary(Of String, ColumnSeries)()
    Protected Sub RadPivotGrid1_CellDataBound(sender As Object, e As PivotGridCellDataBoundEventArgs)
        Dim dataCell As PivotGridDataCell = TryCast(e.Cell, PivotGridDataCell)
        If columnNames.Count = 0 Then
            Me.RadHtmlChart1.PlotArea.XAxis.Items.Clear()
            Me.RadHtmlChart1.PlotArea.Series.Clear()
        End If
        If dataCell IsNot Nothing AndAlso dataCell.CellType = PivotGridDataCellType.DataCell Then
            Dim rowName As String = GetName(dataCell.ParentRowIndexes)
            Dim columnName As String = GetName(dataCell.ParentColumnIndexes)
            columnName = columnName.Replace("'", " ")
            If columnNames.Add(columnName) Then
                Dim axisItem As New AxisItem(columnName)
                RadHtmlChart1.PlotArea.XAxis.Items.Add(axisItem)
            End If
            RadHtmlChart1.PlotArea.XAxis.LabelsAppearance.RotationAngle = 45
            Dim columnSeries As ColumnSeries = Nothing
 
            If columnSeriesByRowName.ContainsKey(rowName) Then
                columnSeries = columnSeriesByRowName(rowName)
            Else
                columnSeries = New ColumnSeries()
                columnSeriesByRowName.Add(rowName, columnSeries)
                columnSeries.Name = rowName
                ' columnSeries.LabelsAppearance.DataFormatString = "C"
                columnSeries.LabelsAppearance.Visible = False
                columnSeries.LabelsAppearance.RotationAngle = 45
                columnSeries.TooltipsAppearance.DataFormatString = "{0} " & rowName
                columnSeries.Stacked = True
                Me.RadHtmlChart1.PlotArea.Series.Add(columnSeries)
            End If
            Dim item As New CategorySeriesItem()
            Dim value As Decimal = 0
            If e.Cell.DataItem IsNot Nothing AndAlso Decimal.TryParse(e.Cell.DataItem.ToString(), value) Then
                item.Y = value
            Else
                item.Y = Nothing
            End If
            columnSeries.SeriesItems.Add(item)
        End If
    End Sub
 
    Private Function GetName(indexes As Object()) As String
        Dim builder As New StringBuilder()
        For Each index As Object In indexes
            builder.Append(index.ToString())
            builder.Append(" / ")
        Next
        builder.Remove(builder.Length - 3, 3)
        Return builder.ToString()
    End Function
 
    Private Sub PopulateSQLDataSource()
 
        SqlDataSource1.SelectCommand = "SELECT Project.ProjectName, SUM( DATEDIFF(HOUR, DbProvider_Classes.Start, DbProvider_Classes.[End])) AS Duration, Users.DisplayName
FROM     Project INNER JOIN
                  DbProvider_Classes ON Project.ProjectID = DbProvider_Classes.ProjectID INNER JOIN
                  Users ON DbProvider_Classes.UserID = Users.UserID
                  INNER JOIN Tasks ON DbProvider_Classes.TaskID = Tasks.TaskID
                  WHERE Tasks.DepartmentID <> 6
                  GROUP BY Project.ProjectName , Users.DisplayName ORDER BY Project.ProjectName ASC"
        SqlDataSource1.Select(DataSourceSelectArguments.Empty)
        SqlDataSource1.DataBind()
        RadPivotGrid1.DataBind()
    End Sub
Private Sub btnViewAll_Click(sender As Object, e As EventArgs) Handles btnViewAll.Click
        PopulateSQLDataSource()
        lblReportDate.Text = "Report Date: Until " & Today.Date.ToString
 
    End Sub

 

If i create the same report with report designer everything works fine and i can load the generated report file from report viewer within my page but i want the client side capabilities of the HTMLChart

 

Thanks

 

 

 

Maria Ilieva
Telerik team
 answered on 09 Jul 2015
4 answers
598 views

Hi,

I have been facing the following problem.

The grid is declared as follows.

 

<

 

telerik:RadGrid ID="RadGrid1" EnableViewState="true" runat="server" GridLines="Vertical" AllowFilteringByColumn="false" AutoGenerateColumns="false" AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" ShowStatusBar="true" AllowMultiRowSelection="true" Height="600px">

 

Grid columns are defined as follows; Please note the DataKeyNames property.

<
MasterTableView BorderStyle="None" BorderWidth="0" AllowCustomSorting="true" DataKeyNames="col1">
 <telerik:GridBoundColumn UniqueName="item_num" DataField="item_num" DataType="System.Int32" SortExpression="item_num"  
 HeaderText
="item number">

 

 

 

</telerik:GridBoundColumn>

 

I have multi row select enabled on the grid. After selecting multiple rows, I run the following Javascript to get the value of the data key for those rows but it returns null for

var radgrdItems = $find("<%=RadGrid1.ClientID %>");
var mtv = radgrdItems.get_masterTableView();

// Get array of GridDataItem
var selectedRows = mtv.get_selectedItems();

// Works as expected. Returns the count of selected rows.
alert(selectedRows.length);

for (var i = 0; i < selectedRows.length; i++) {
   var row = selectedRows[i];
   if (row == null)
     alert("row is null");
   else {
      // Works as expected - Returns the id
      alert("get_id()= " + row.get_id());

      // Does not work! Returns null for the get_dataItem()["item_num"]
      alert("item #=" + row.get_dataItem()["item_num"]);

      // Does not work! Returns null for the row.getDataKeyValue("col1")
      alert("col1 key value=" + row.getDataKeyValue("col1"));
   }


What am I doing wrong?

I have already looked @ http://demos.telerik.com/aspnet-ajax/grid/examples/client/keys/defaultcs.aspx page and could not find the issue in my code (may be I am missing something?)

Any help is appreciated.

Thanks,
Manny

Daniel
Telerik team
 answered on 09 Jul 2015
1 answer
69 views
Please consider specific components to build for color themes for people with disabilities, namely:

black on yellow - black components with yellow lettering, background pages yellow

yellow on black - yellow components with black lettering, black page background

Such are the demands of EU state administrations of the Member States and therefore there is need to build such motives. It is not easy for a programmer who does not know the inside of your components.

At the same time ask for information, when available new Visual Style Builder.
Ivan Zhekov
Telerik team
 answered on 09 Jul 2015
1 answer
84 views

Hello everyone

Hopefully I am being stupid but I have the following problem with the rad file explorer. I've set it so a user can upload and delete files. If Istart with a blank cancas, i.e. nothing present in any existing folders and add/delete files, absolutely no problem at all (see Working.gif)

However, if I already have an existing file present in my file path, I experience a bit of nasty stuff (see NotWorking.gif) - as you can see, the file appears to be present, it isn't, it has been removed from the filepath as requested hence you see the 'resource not found' error when I attempt to open it.

Here is the code I have.

Markup

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!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>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            (function (global, undefined) {
                function OnClientFileOpen(oExplorer, args) {
                    var item = args.get_item();
                    var fileExtension = item.get_extension();
 
                    var fileDownloadMode = true;
                    if ((fileDownloadMode == true) && (fileExtension == "txt" || fileExtension == "xls" || fileExtension == "xlsx")) {// Download the file
                        // File is a image document, do not open a new window
                        args.set_cancel(true);
 
                        // Tell browser to open file directly
                        var requestImage = "Handler.ashx?path=" + item.get_url();
                        document.location = requestImage;
                    }
                }
 
            global.OnClientFileOpen = OnClientFileOpen;
        })(window);
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Configuratorpanel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadFileExplorer1" LoadingPanelID="theLoadingPanel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div>
 
 
            <telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" Width="595px" Height="320px"
                OnClientFileOpen="OnClientFileOpen" EnableOpenFile="true">
                <Configuration MaxUploadFileSize="51200000"></Configuration>
            </telerik:RadFileExplorer>
 
 
        </div>
    </form>
</body>
</html>

C#

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //set properties according to configuration panel
        RadFileExplorer1.Configuration.SearchPatterns = new string[] { "*.jpg", "*.jpeg", "*.gif", "*.png", "*.txt", "*.xls", "*.xlsx" };
        RadFileExplorer1.VisibleControls = GetVisibleControls();
 
        //Set initial folder to open. Note that the path is case sensitive!
        //var filePath = "~/TestData";
        var filePath = "~/TestData/6645dc9a-5e8c-46e9-aad0-ba9b087aae4a";
        //var filePath = "~/TestData/a4089fd8-3170-4956-a8f5-1ea21a19d984";
 
        RadFileExplorer1.Configuration.UploadPaths = new string[] { filePath };
        RadFileExplorer1.Configuration.ViewPaths = new string[] { filePath };
        RadFileExplorer1.Configuration.DeletePaths = new string[] { filePath };
 
        if (!IsPostBack)
        {
            //Set initial folder to open. Note that the path is case sensitive!
            RadFileExplorer1.InitialPath = Page.ResolveUrl(filePath);
        }
 
    }
    protected Telerik.Web.UI.FileExplorer.FileExplorerControls GetVisibleControls()
    {
        Telerik.Web.UI.FileExplorer.FileExplorerControls explorerControls = 0;
        explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.All;
        return explorerControls;
 
    }
}

If anyone can point out what I am doing wrong or what else I may need to implement, I'd be most grateful.

Rich

 

Vessy
Telerik team
 answered on 09 Jul 2015
1 answer
115 views
Is it possible to have the ConfigurationPanelSettings panel in the radpivot slide so the configuration panel can be hidden when not needed and provide more screen space for the pivot table?
Eyup
Telerik team
 answered on 09 Jul 2015
4 answers
200 views
I have a rad pivot grid and I am trying to export the grid to pdf and csv.  I am able to export it to excel.   Is there a work around to get it exported to other formats.  Would appreciate any suggestions you might have.

I tried this for .csv  but I am unable to get any data.  

protected void btnExportCSV_Click(object sender, EventArgs e)
 {
  Response.Clear();
  Response.Buffer = true;
  Response.AddHeader("content-disposition",
   "attachment;filename=GridViewExport.csv");
  Response.Charset = "";
  Response.ContentType = "application/text";

  RadPivotGrid1.AllowPaging = false;
  RadPivotGrid1.DataBind();

  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < RadPivotGrid1.Fields.Count; i++)
  {   
    //add separator
   sb.Append(RadPivotGrid1.Fields[i].ToString() + ',');
   }
   //append new line
   sb.Append("\r\n");
   lblTest.Text = sb.ToString();
  Response.Output.Write(sb.ToString());
  Response.Flush();
  Response.End();
 }

I think I am not doing this right?  What is the best way to loop through the cells in a pivot grid and get data.  
  for (int i = 0; i < RadPivotGrid1.Fields.Count; i++)
  {   
    //add separator
   sb.Append(RadPivotGrid1.Fields[i].ToString() + ',');
   }

Thanks
nagaraju
Top achievements
Rank 1
 answered on 09 Jul 2015
1 answer
536 views

Hi there,

I do need to create 3 new columns dynamically according to the data existence in the database. This approach has been done successfully and it works very well.

 The issue occurs once the user clicks on the export button and the header does disappear and the data appears as "System.Data.DataRowView" in the excel sheet.

The following event is to load the grid. I do need to create programmatically, because I have to rename the column header according to the data that I receive. 

//Add in name column
                GridBoundColumn col = new GridBoundColumn();
                col.HeaderText = addition1;
                col.DataField = "Additional1";
                col.UniqueName = "Additional1";
                // col.Display = false;
                RadGrid1.MasterTableView.Columns.Add(col);
                col = new GridBoundColumn();
                col.HeaderText = addition2;
                col.DataField = "Additional2";
                col.UniqueName = "Additional2";
                // col.Display = false;
                RadGrid1.MasterTableView.Columns.Add(col);
                col = new GridBoundColumn();
                col.HeaderText = addition3;
                col.DataField = "Additional3";
                col.UniqueName = "Additional3";
                //col.Display = false;
                RadGrid1.MasterTableView.Columns.Add(col);
 

So, after the above code, I do create a Data Table and bind the data in it and bind the Data Table in RadGrid.DataSource.

The look of the grid is okay. That means the column and the data are appearing perfectly. 

However, once it comes on the excel file, the column text disappears and the content for these columns are appearing as "System.Data.DataRowView"

What could be the reason? - Thank you

Mehmet
Top achievements
Rank 1
 answered on 09 Jul 2015
1 answer
117 views

Good morning

I'd like to know if there is a full functionality for QR Code in UI for Asp.net AJAX 2012.2.815. I have a purchased license and I need to know if I can embed the whole QR Code functionality without purchasing a new product (for example the latest version of 2015). If there is that possibility what is the estimated cost for this?

Thnx

Billy P.

Athens

Pavlina
Telerik team
 answered on 08 Jul 2015
2 answers
192 views

I have been following this thread (http://www.telerik.com/forums/radasyncupload-clear-items-using-serverside-code) for a similar issue.

Issue: "I am using RadAsyncUpload to upload files. I have a 'Cancel' button which the user can click anytime after selecting the files. I want to clear the selected files - or in other words reset the RadAsyncUpload Control when 'Cancel' button is clicked." (by Liby George)

Solution: Please include the following line of code in your click handler for the "Cancel" button.
//JavaScript
$telerik.$(".ruInputs li .ruRemove").click()
This will go through the files <li> elements and click on the "Remove" link.  (by Boyan Dimitrov)

My problem: Since there are severals RadAsyncUpload along with coresponding buttons in one page, this will clear all selected files of all upload controls for a single click . How can I clear the items of one RadAsyncUpload without affecting the others?

Hristo Valyavicharski
Telerik team
 answered on 08 Jul 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?