Horizontal scroll without fix grid width

2 posts, 0 answers
  1. Михаил
    Михаил avatar
    1 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2015 Link to this post



    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>
                            <telerik:GridGroupByField FieldAlias="FacultyName" HeaderText="Факультет" FieldName="FacultyName" />
                            <telerik:GridGroupByField FieldName="FacultyName" />
            <CommandItemSettings ShowAddNewRecordButton="False" SaveChangesText="Сохранить" CancelChangesText="Отменить изменения" RefreshText="Обновить"></CommandItemSettings>
        <PagerStyle AlwaysVisible="True"></PagerStyle>
        <ClientSettings AllowKeyboardNavigation="True">
            <Scrolling AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="5"></Scrolling>


    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)



  2. Pavlina
    Pavlina avatar
    6184 posts

    Posted 06 Oct 2015 Link to this post


    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.

    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
Back to Top