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

unable to fix the height and width of column having image in it

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shashikant
Top achievements
Rank 1
Shashikant asked on 31 Oct 2014, 07:05 AM
hi,

I am want to fix the height and width of column which has image displayed. Actually, all the images being called in the cell are of different size this causes the design messed up.

I tried Item style height and width but it didn't solved the problem.

here is the code
<telerik:RadGrid ID="RadGrid_Banner_Home_Main" runat="server" AllowFilteringByColumn="True"
                        AutoGenerateColumns="false" AllowSorting="True" PageSize="10" ShowFooter="False"
                        ShowGroupPanel="False" AllowPaging="true" Skin="Vista" EnableLinqExpressions="false">
                        <PagerStyle Mode="NextPrevAndNumeric" />
                        <ExportSettings IgnorePaging="true" FileName="banner_Export" Pdf-AllowAdd="true"
                            Pdf-AllowCopy="true" Pdf-AllowPrinting="true" Pdf-PaperSize="A4" Pdf-Creator="a1"
                            OpenInNewWindow="true" ExportOnlyData="true" />
                        <MasterTableView DataKeyNames="banner_id" HorizontalAlign="NotSet" AutoGenerateColumns="False"
                            AllowFilteringByColumn="True" AllowSorting="true"  AlternatingItemStyle-BackColor="#f3f3f3"
                            CommandItemDisplay="Top" ClientDataKeyNames="banner_id">
                            <CommandItemSettings ShowExportToWordButton="false" ShowExportToExcelButton="false"
                                ShowExportToPdfButton="false" ShowExportToCsvButton="false" ShowAddNewRecordButton="false"
                                ShowRefreshButton="false" />
                            <NoRecordsTemplate>
                                Banner not available
                            </NoRecordsTemplate>
                            <SortExpressions>
                                <telerik:GridSortExpression FieldName="image" SortOrder="Ascending" />
                            </SortExpressions>
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Banner" DataField="image" UniqueName="image"
                                    HeaderStyle-Width="100" ItemStyle-Width="100" ItemStyle-Height="100"
                                    AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" AllowFiltering="false"
                                    GroupByExpression="image [Banner] Group By image">
 
                                    <ItemTemplate>
                                        <asp:Label ID="lbl_img_path" runat="server" Text='<%#Eval("image")%>' Visible="false"></asp:Label>
                                        <%# IIf(Container.DataItem("banner_type") <> "HTML", "" & "<img src=" & Gogotech.SqlHelper.of_FetchKey("FrontEndServer") & IIf(Eval("image") <> "", Eval("image"), "/images/ina.jpg") & " />" & "", "" & Eval("html") & "")%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
      </Columns>
                        </MasterTableView>
               
                    </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Nov 2014, 07:53 AM
Hello,

Could you try setting fixed width through HeaderStyle-Width property of the template column in px as shown below and see if it helps. Note that you should not use ItemStyle-Width for setting column width:
<telerik:GridTemplateColumn HeaderText="Banner" DataField="image" UniqueName="image"
HeaderStyle-Width="100px"  AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" AllowFiltering="false"  GroupByExpression="image [Banner] Group By image">
  <ItemTemplate>
     <asp:Label ID="lbl_img_path" runat="server" Text='<%#Eval("image")%>' Visible="false"></asp:Label>
          <%# IIf(Container.DataItem("banner_type") <> "HTML", "" & "<img src="Gogotech.SqlHelper.of_FetchKey("FrontEndServer") & IIf(Eval("image") <> "", Eval("image"), "/images/ina.jpg") & " />" & "", "" & Eval("html") & "")%>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Also setting ItemStyle-Height is of no use in your case because table cells cannot be prevented from expanding vertically. You can try adding some container with fixed height in the template column as recommended in the following forum post:
http://www.telerik.com/forums/radgrid-max-height

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Shashikant
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or