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

Problem with BinaryImage control in Grid

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Donald Norris
Top achievements
Rank 1
Donald Norris asked on 26 Apr 2010, 12:45 AM
I have attached code and sample output.  I have a binary image control in a column.  I load the control for each row in the grid and it displays correctly.  When I click on a row the corresponding PDF document is displayed correctly. however, the grid looks empty but the contents have actually moved way down the page.  Could you please tell me what I am doing wrong?

Thanks

{
    DocGrid = sender;
}
function DocRowSelected(sender, eventArgs) {
    // alert("Click on row with index: " + rowIndex);
    var MasterTable = DocGrid.get_masterTableView();
    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
    var path = MasterTable.getCellByColumnUniqueName(row, "DT_FilePath").innerHTML;
    var Filename = MasterTable.getCellByColumnUniqueName(row, "DT_FileName").innerHTML;
    var Pgm
    Pgm = "DisplayDocument.aspx?File=" + path + Filename;
    open(Pgm);

}


<telerik:RadGrid ID="DocGrid" runat="server" AutoGenerateColumns="False"  Visible="False"
    DataSourceID="docDS" Skin="" OnItemDataBound="DocGrid_ItemDataBound" 
    Width="1000px" Height="800px" HorizontalAlign="Center" AllowSorting="True" >
            <ClientSettings >
                <Selecting AllowRowSelect="True"></Selecting>
                <ClientEvents OnRowClick="DocRowSelected" OnGridCreated="DocGridCreated">
                </ClientEvents>
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
<MasterTableView DataSourceID="docDS" GridLines="Both">
    <Columns>
        <telerik:GridTemplateColumn UniqueName="imageColumn">
            <ItemTemplate>
                <telerik:RadBinaryImage ID="myPDF" runat="server" Height="260" Width="200" />
            </ItemTemplate>
            <HeaderStyle Width="200px" />
            <ItemStyle Height="260px" Width="200px" />
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn DataField="DT_FileNum" Display="False"
            HeaderText="DT_FileNum" SortExpression="DT_FileNum" UniqueName="DT_FileNum">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_Desc" HeaderText="Document"
            SortExpression="DT_Desc" UniqueName="DT_Desc">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="400px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Left"
                Width="400px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_DateTime"
            DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"
            HeaderText="Create Date" SortExpression="DT_DateTime" UniqueName="DT_DateTime">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="150px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Center"
                Width="150px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_Clerk" HeaderText="Clerk"
            SortExpression="DT_Clerk" UniqueName="DT_Clerk">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="200px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Center"
                Width="200px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_FilePath" Display="False"
            HeaderText="DT_FilePath" SortExpression="DT_FilePath" UniqueName="DT_FilePath">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_FileName" Display="False"
            HeaderText="DT_FileName" SortExpression="DT_FileName" UniqueName="DT_FileName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_DocumentCategory" Display="False"
            HeaderText="Category" SortExpression="DT_DocumentCategory"
            UniqueName="DT_DocumentCategory">
            <HeaderStyle Font-Bold="True" Width="80px" />
            <ItemStyle Font-Size="Small" />
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
  
</telerik:RadGrid>

    Protected Sub DocGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
        Dim GridItem As GridDataItem
        Dim myImage As PdfRasterizer
        Dim MyControl As RadBinaryImage
        Dim myImageSize As FixedImageSize = New FixedImageSize(196, 254)
        If Not TypeOf (e.Item) Is GridDataInsertItem Then
            If (TypeOf (e.Item) Is GridDataItem) Then
                Dim databounditem As GridDataItem = e.Item
                GridItem = e.Item
                ceTe.DynamicPDF.Rasterizer.PdfRasterizer.AddLicense("RST10NXDFAAALGWbGdA/Ngn6wTGmkU9PgO+wQPvVJHzsB7defcssnA4G1RG1bjmjlNG8QillITKUiVQt7T27hvFr1kacZA0rklJg")
                Try
                    If Left(databounditem("DT_Desc").Text, 11) = "Unspecified" Then
                        databounditem("DT_Desc").Text = Replace(databounditem("DT_Desc").Text, "Unspecified Service - ", "")
                    End If
                    myImage = New PdfRasterizer(Server.MapPath(BLLayer.ImagingVirtualPath) & "\" & databounditem("DT_FilePath").Text & databounditem("DT_FileName").Text)
                    MyControl = DirectCast(GridItem("imageColumn").FindControl("MyPDF"), RadBinaryImage)
                    MyControl.DataValue = myImage.Pages(0).Draw(ceTe.DynamicPDF.Rasterizer.BmpImageFormat.Bmp, myImageSize)
                Catch ex As Exception
                    If BLLayer.EmailErrors Then
                        BLLayer.MailException(ex, "QueryFinal error on Document tab.")
                    Else
                        Session("EX") = ex.Message
                        Session("EX2") = "QueryFinal error on Document tab."
                        Response.Redirect("ProgramError.aspx")
                    End If
                End Try
            End If
        End If
       
    End Sub

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 29 Apr 2010, 07:46 AM
Hello Donald,

Thanks for the sample code. The code actually seems fine. Also the difference between the 2 screen shots is that one does not display the grid header. I couldn't quite understand what is the issue. Could you, please, clarify. The grid should not be changing when you open a new window containing the PDF document.

Greetings,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Donald Norris
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or