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

Horizontal scroll without fix grid width

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Михаил
Top achievements
Rank 1
Михаил asked on 01 Oct 2015, 01:33 PM

Hello!

 

I have a problem with horizontal scroll in grid. I generete programmatically columns with fixed width in HeaderStyle.Width on OnInit event, and this grid

 

<div style="width: 100%; display: block;">
<telerik:RadGrid ID="gvMain" Width="100%" runat="server" OnNeedDataSource="gvMain_OnNeedDataSource" OnBatchEditCommand="gvMain_OnBatchEditCommand"
     AutoGenerateColumns="False" AllowPaging="True" PageSize="100" AllowSorting="True" AllowFilteringByColumn="True" Skin="Metro" Culture="ru-Ru">
    <MasterTableView CommandItemDisplay="TopAndBottom" AllowAutomaticUpdates="True" EditMode="Batch" AllowAutomaticDeletes="False"
        AllowAutomaticInserts="False" DataKeyNames="PersonId" TableLayout="Fixed">
        <BatchEditingSettings EditType="Cell"></BatchEditingSettings>
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                    <SelectFields>
                        <telerik:GridGroupByField FieldAlias="FacultyName" HeaderText="Факультет" FieldName="FacultyName" />
                    </SelectFields>
                    <GroupByFields>
                        <telerik:GridGroupByField FieldName="FacultyName" />
                    </GroupByFields>                           
                </telerik:GridGroupByExpression>
            </GroupByExpressions>
        <CommandItemSettings ShowAddNewRecordButton="False" SaveChangesText="Сохранить" CancelChangesText="Отменить изменения" RefreshText="Обновить"></CommandItemSettings>
    </MasterTableView>
    <PagerStyle AlwaysVisible="True"></PagerStyle>
    <ClientSettings AllowKeyboardNavigation="True">
        <Scrolling AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="5"></Scrolling>
    </ClientSettings>
     
</telerik:RadGrid>
     
</div>

 

When sum of columns width  exceed the page width, I have the Page horizontal scroll instead grid scrolling. How can I fit Grid into parent div? (It's normally work with PivotGrid, but not with a Grid)

 

 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 06 Oct 2015, 12:31 PM
Hello,

Try setting Column widths inside PreRender event of the grid, traverse the Columns collection to locate the column of interest, and set its HeaderStyle.Width property. You must then rebind the grid by calling its Rebind() method to reflect the changes.

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
Михаил
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or