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

Setting column width using CSS

1 Answer 279 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jmillar
Top achievements
Rank 1
jmillar asked on 25 Feb 2016, 12:01 PM

Hi there;

I have a grid with column definitions similar to the following:

<telerik:GridNumericColumn UniqueName="R1" Visible="true" ReadOnly="false" HeaderText="Q1" DataField="R1" DataFormatString="{0:0}%" HeaderStyle-CssClass="EntryColumn" ItemStyle-CssClass="EntryColumn" />

The EntryColumn class just has a simple width:30px definition, with nothing else.

The grid respects the column width until I add the Command Bar display - with that on, it reverts to just showing the columns in the default width.  I can fix it using ItemStyle-Width, but I'd rather use a class definition as I have several of these types of grids scattered throughout the app.

Anybody know what I'm doing wrong?

Thanks,

Jason

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Mar 2016, 12:30 PM
Hi,

Below is a sample page I tested locally and setting column width is working as expected. Try it on your end and let me know if it helps. Also make sure that MasterTableView TableLayout is set to Fixed:
<style>
        .EntryColumn
        {
            width: 30px;
        }
    </style>


<telerik:RadGrid ID="grd" runat="server" AutoGenerateColumns="false" AllowPaging="True"
            OnNeedDataSource="grd_NeedDataSource" PageSize="10">
            <MasterTableView AllowFilteringByColumn="True" CommandItemDisplay="Top" AllowSorting="True"
                CanRetrieveAllData="False" EnableColumnsViewState="True" EnableViewState="True" TableLayout="Fixed">
                <PagerStyle AlwaysVisible="true" />
                <Columns>
                    <telerik:GridNumericColumn UniqueName="DisplayOrder" Visible="true" ReadOnly="false" HeaderText="Q1" DataField="DisplayOrder"
                        DataFormatString="{0:0}%" HeaderStyle-CssClass="EntryColumn" ItemStyle-CssClass="EntryColumn" />
                    <telerik:GridBoundColumn DataField="Status" HeaderText="Status">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>


Regards,
Pavlina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
jmillar
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or