Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
102 views

I currently able to export multiple grids to excel in one file. Problem is that me superiors would like it to be prettier.

Is there a way to export multi grids in html format? Please help!

My current export code is this:

                   Dim gridControlsFound As New List(Of RadGrid)()

                    gridControlsFound.Add(grdBCA_Assumptions_TravelDemand)
                    gridControlsFound.Add(grdBCA_Assumptions_StartupCosts)
                    gridControlsFound.Add(grdBCA_Assumptions_AnnualCosts)

                    ExportMultiGrid(gridControlsFound, "GrantReport")

Private Sub ExportMultiGrid( _
                            ByVal gridControlsFound As List(Of RadGrid), _
                            ByVal FileName As String)

        Dim tableXLS As New xls.Table()
        Dim ExportInSingleSpreadsheet As Boolean = True

        For Each grid As RadGrid In gridControlsFound
            grid.AllowPaging = False
            grid.CurrentPageIndex = 0
            'grid.Rebind()
            GenerateTable(grid, tableXLS)
        Next

        If ExportInSingleSpreadsheet = True Then
            [structure].Tables.Add(tableXLS)
        End If

        Dim renderer As New xls.XlsBiffRenderer([structure])
        Dim renderedBytes As Byte() = renderer.Render()
        Response.Clear()
        Response.AppendHeader("Content-Disposition:", "attachment; filename=" & FileName & ".xls")
        Response.ContentType = "application/vnd.ms-excel"
        Response.BinaryWrite(renderedBytes)
        Response.[End]()

    End Sub

 

 Private Sub GenerateTable(grid As RadGrid, ByRef singleTable As xls.Table)

        Dim ExportInSingleSpreadsheet As Boolean = True

        If ExportInSingleSpreadsheet = False Then
            singleTable = New xls.Table(grid.ID)
            row = 1
            col = 1
        Else
            If Not isFirstItem Then
                row += 1
            Else
                isFirstItem = False
            End If
        End If

         For i As Integer = 0 To grid.Columns.Count - 1

            If grid.Columns(i).HeaderText.Length = 1 Then
                If grid.Columns(i).UniqueName = "Discount1" Then
                    singleTable.Cells(i + 1, row).Value = txbDiscountRate_1.Text & "% discount rate ($ mil.)"
                ElseIf grid.Columns(i).UniqueName = "Discount2" Then
                    singleTable.Cells(i + 1, row).Value = txbDiscountRate_2.Text & "% discount rate ($ mil.)"
                Else
                    singleTable.Cells(i + 1, row).Value = grid.Columns(i).HeaderText
                End If
            Else
                singleTable.Cells(i + 1, row).Value = grid.Columns(i).HeaderText
            End If

        Next

        row += 1

        For Each item As GridDataItem In grid.MasterTableView.Items
            For Each column As GridColumn In grid.Columns
                singleTable.Cells(col, row).Value = item(column.UniqueName).Text
                col += 1
            Next
            col = 1
            row += 1
        Next

        If ExportInSingleSpreadsheet = False Then
            [structure].Tables.Add(singleTable)
        End If

    End Sub

David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 08 Apr 2016
4 answers
107 views
Hi,
I have radtreemap that has a single parent_id.
At the moment it’s all renders in pretty much the same colour, (albeit slightly different tones)
Is there a way to force each item (square) to have a different colour?
Thanks.
Ivan Danchev
Telerik team
 answered on 08 Apr 2016
14 answers
539 views
Is it possible to use the export to pdf function of a radgrid to save the outputted pdf on the server? Essentially what I am trying to accomplish is to have a page with a bunch of user inputs and then when the user clicks the submit button it would save the page with everything that they have typed in as a pdf. I was hoping to achieve this by putting the entire page inside of a radgrids item template and then in the submit buttons code behind, I would like to export the grid to pdf and save it in a directory on the server. Is this at all possible? Is there an example somewhere on how to do it? Is this even the best approach to take?
Daniel
Telerik team
 answered on 08 Apr 2016
1 answer
89 views

hi

 

The radlistbox is not showing or displaying anything on screen. Why is that so? Thanks

 

here is my code:

 

 <telerik:RadListBox ID="lbList"  runat="server" BorderWidth="0px" BorderStyle="None" Width="100%" style="top: 0px; left: 0px"  BorderColor="White">            <ItemTemplate>
             <table>
                 <tr>
                    <td ><asp:Image ID="Image1" runat="server" ImageUrl="~/crm/profileimage/freelance.png" /></td>
                    <td>John Wayne</td>
                </tr>
             </table>
        </ItemTemplate>
</telerik:RadListBox>

Pavlina
Telerik team
 answered on 08 Apr 2016
1 answer
100 views

 

Checkboxes in a batch grid require an extra click to put them into Edit mode, but that's fixed with this code I got on this forum...

function changeEditor(sender) {
    var grd = GetControlRAD("grdPODetails");
    var batchManager = grd.get_batchEditingManager();
    batchManager.openCellForEdit(sender.parentElement.parentElement);
    sender.checked = !sender.checked;
}

<telerik:RadGrid ID="grdPODetails" runat="server" AllowSorting="True" AutoGenerateColumns="False" Skin="Office2010Blue" GridLines="None">
    <HeaderContextMenu EnableAutoScroll="True">
    </HeaderContextMenu>
    <MasterTableView CommandItemDisplay="Top" EditMode="Batch" InsertItemDisplay="Bottom"
            ClientDataKeyNames="PurchaseOrderDetailKey"
            DataKeyNames="PurchaseOrderDetailKey">
        <BatchEditingSettings EditType="Cell" OpenEditingEvent="Click" />
        <CommandItemSettings ShowRefreshButton="False" ShowSaveChangesButton="true" ShowCancelChangesButton="true" />
        <NoRecordsTemplate>
            No detail lines to display.
        </NoRecordsTemplate>
        <Columns>
 
            <telerik:GridTemplateColumn DataField="PrintOnPurchaseOrder" HeaderText="Print" UniqueName="PrintOnPurchaseOrder" DataType="System.Boolean">
                <HeaderStyle Width="40px" />
                <ItemStyle Width="40px" />
                <ItemTemplate>
                    <input id="chkPrint" type="checkbox" checked='<%# Eval("PrintOnPurchaseOrder") %>' onclick="changeEditor(this);" />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="chkPrint" runat="server" Checked='<%# Bind("PrintOnPurchaseOrder") %>' />
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn DataField="PostToGeneralLedger" HeaderText="Post" UniqueName="PostToGeneralLedger" DataType="System.Boolean">
                <HeaderStyle Width="40px" />
                <ItemStyle Width="40px" />
                <ItemTemplate>
                    <input id="chkPost" type="checkbox" checked='<%# Eval("PostToGeneralLedger") %>' onclick="changeEditor(this);" />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="chkPost" runat="server" Checked='<%# Bind("PostToGeneralLedger") %>' />
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
 
            <telerik:GridTemplateColumn DataField="UnitDescription" UniqueName="UnitDescription" HeaderText="Unit Desc" DataType="System.String">
                <ItemTemplate>
                    <asp:Label ID="lblUnitDescription" runat="server"
                        Text='<%# Eval("UnitDescription") %>'>
                    </asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadTextBox ID="txtUnitDescription" runat="server" MaxLength="10" Width="100%"
                    Text='<%# Bind("UnitDescription") %>' >
                    </telerik:RadTextBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
 
        </Columns>
    </MasterTableView>
    <ClientSettings AllowKeyboardNavigation="true">
        <Selecting AllowRowSelect="True" />
        <ClientEvents/>
    </ClientSettings>
</telerik:RadGrid>

 

A breakpoint in changeEditor shows it's only called once, to put it in edit mode. But the first time you click it (and every time following if you keep clicking it while still in edit mode) I need to handle that event. For instance, in this grid, if I check the checkbox in the 2nd column, how can I set column "UnitDescription" in the same row to "A", but if I uncheck the checkbox (while still in EditMode) it sets UnitDescription" to "B"?

I tried putting an event handler on the checkbox within EditItemTemplate, but that didn't work... or I did it wrong. It's almost like when it opens in edit mode, a new checkbox is created on the fly. But I can't figure out where it is or how to grab its events. Please help.

 

Kostadin
Telerik team
 answered on 08 Apr 2016
1 answer
90 views

Hello,

I have a RadGrid inside a Asp repeater. 0 to 15 grids are built depending on the user preferences through the repeater. I placed a Response.Write([Method Name]) in the events and this is one I obtained for 2 grid containing 5 rows each. The repeater Repeater.DataBind() is called when the user clicks on a button.

Button_Click begin
Repeater_DataBinding begin
Repeater_DataBinding end
    RadGrid_NeedDataSource begin
    RadGrid_NeedDataSource end
        RadGrid_ItemDataBound begin
        RadGrid_ItemDataBound end     (occured 24 times)
Repeater_ItemDataBound begin
        RadGrid_ItemDataBound begin
        RadGrid_ItemDataBound end     (occured 12 times)
Repeater_ItemDataBound end
    RadGrid_NeedDataSource begin
    RadGrid_NeedDataSource end     (occured 24 times)
Repeater_ItemDataBound begin
        RadGrid_ItemDataBound begin
        RadGrid_ItemDataBound end     (occured 12times)
Repeater_ItemDataBound end
Button_Click end

I am not sure why each grid runs ItemDataBound twice that many times (24 times = (5 rows + header) x 4 and then 12 times = (5 rows + header) x 2).

I would also expect RadGrid_NeedDataSource to be inside the Repeater_ItemDataBound scope.

Maria Ilieva
Telerik team
 answered on 08 Apr 2016
3 answers
184 views
Hi,

I tried loading the SessionDataSource.cs to my app_code folder but still receive the error:

Generation of designer file failed: Unknown server tag sds:SessionDataSource.  I'm able to compile fine.  However this doesn't work.

Please help.
Thanks,
Nencho
Telerik team
 answered on 08 Apr 2016
5 answers
164 views
hi,
    i am using the prometheus schedular in my web application.after uploading the application i m trying to run the application but i m getting the error shown below.how can i parse the session datasource.can anyone plz help me inthis regard.


Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'sds:SessionDataSource'.

and

Source Error:

Line 232:    
Line 233:            
Line 234:<sds:SessionDataSource ID="AppointmentsDataSource" runat="server" DisplayWarning="false"
Line 235:PrimaryKeyFields="ID" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>"
Line 236:SelectCommand="SELECT * FROM [Appointments]" InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [RoomID], [UserID], [RecurrenceRule], [RecurrenceParentID]) VALUES (@Subject, @Start, @End , @RoomID, @UserID, @RecurrenceRule, @RecurrenceParentID)"

Syna-G team
Nencho
Telerik team
 answered on 08 Apr 2016
2 answers
293 views
Does anyone know of any 3rd party asp.net components or methods for performing virus scans of files being uploaded through Rad Upload? I imagine Telerik must implement some sort of system. Perhaps they can be of assistance.
Veselin Tsvetanov
Telerik team
 answered on 08 Apr 2016
2 answers
230 views

We are upgrading from version 2011.1.519.35 to 2015.3.1111.35 and are having trouble with changes in how the editor behaves with contenteditable=false.

We have functionality that lets users add "mail merge fields" to the content in the editor. When they click a button, we use the editor's pasteHtml() function to add an HTML snippet containing information about the "field." Because we don't want the user to change the information within the field, just add or delete it as a single unit, we use contenteditable=false within its tags.

The problem is that in the 2011 editor, the user could continue typing after we inserted the snippet. But in the 2015 editor, the user's cursor seems to get trapped inside the snippet, and they are unable to continue editing past the snippet.

Is there a way around this? Or, is there a different way we can implement this kind of functionality that works better with the current editor?

Below is a sample ASPX page where you can experience the difference between the versions if you compile it against the 2011.1.519.35 assembly vs 2015.3.1111.35. The way to simulate the issue is to:

  1. Run the project to open the page with the editor
  2. Switch the editor to HTML view
  3. Paste the following HTML: Test <span contenteditable=false>uneditable</span>
  4. Switch to Design view
  5. Move your cursor to the end of the content in the editor and try to type some more content

When using the 2011 editor, you can keep typing, but in the 2015 editor, you can't.

We're using Internet Explorer. (I'm using version 11, and haven't yet tried other versions.) Our pages have the X-UA-Compatible header set to IE=EmulateIE7, due to having some old code, which changes the editor's behavior a slightly in this example, but even without that header, the fundamental difference between the two versions remains:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<!DOCTYPE html>
 
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
</head>
<body>
    <h1><%= FileVersionInfo.GetVersionInfo(RadEditor1.GetType().Assembly.Location).FileVersion %> Telerik</h1>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"/>
        <telerik:RadEditor ID="RadEditor1" Runat="server" />
    </form>
</body>
</html>

 

Amy
Top achievements
Rank 1
 answered on 08 Apr 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?