How to implement horizontal scrollbar in flexgrid with only header information?

Posted by: soumya.mangaraj on 14 April 2020, 2:16 am EST

    • Post Options:
    • Link

    Posted 14 April 2020, 2:16 am EST

    Here we are adding columns dynamically , so we want to display horizontal scroll bar on wijmo flexgrid such that we can display each columns even if there is no data in flexgrid.

    <wj-flex-grid

    #flex

    class=“batch-employee-grid”

    [frozenColumns]=“6”

    [allowAddNew]=“false”

    [allowDelete]=“true”

    [autoGenerateColumns]=“true”

    [allowSorting]=“false”

    [headersVisibility]=“‘Column’”

    [(itemsSource)]=“empGridCollectionView”

    [isReadOnly]=“!canEditBatch”

    [stickyHeaders]=“false”

    selectionMode=“CellRange”

    [validateEdits]=“false”

    (cellEditEnding)=“onCellEditEnding($event)”

    (cellEditEnded)=“onCellEditEnded($event)”

    (keydown.tab)=“onFlexKeyPressTab(flex, $event)”

    (keydown.shift.tab)=“onFlexKeyPressShiftTab(flex, $event)”

    <wj-flex-grid-column [width]=“50” [isReadOnly]=“true”>

    <ng-template wjFlexGridCellTemplate [cellType]=“‘ColumnHeader’”>

    <ng-template wjFlexGridCellTemplate [cellType]=“‘Cell’” let-item=“item” let-cell=“cell”>

    <a (click)=“copyEmployeeRow(item)” [class.grid-link-selected]=“isCellSelected(cell)”>

    <adp-button iconType=“copy” buttonStyle=“link” [disabled]=“!canEditBatch”>







    <wj-flex-grid-column [isReadOnly]=“true” [width]=“50”>

    <ng-template wjFlexGridCellTemplate [cellType]=“‘ColumnHeader’”>

    <ng-template wjFlexGridCellTemplate [cellType]=“‘Cell’” let-item=“item” let-cell=“cell”>{{ cell.row.index + 1 }}



    <wj-flex-grid-column

    *ngFor=“let wijmoHeader of wijmoHeaders”

    [header]=“wijmoHeader.data.m_heading”

    [binding]=“wijmoHeader.columnOptions.binding”

    [isReadOnly]=“wijmoHeader.columnOptions.isReadOnly”

    [visible]=“wijmoHeader.columnOptions.visible”

    [allowDragging]=“wijmoHeader.data.m_fieldCode > 4 ? true : false”

    Please find the attached screenshot below

  • Posted 14 April 2020, 6:41 am EST - Updated 3 October 2022, 4:34 pm EST

  • Posted 15 April 2020, 12:53 am EST

    Hi,

    If you have explicitly set a width of the FlexGrid and the width of the columns is more than that of the assigned width, then a scrollbar will be automatically shown even if there is not data source assigned. Refer to the sample below for reference:

    https://stackblitz.com/edit/angular-ccg7fn

    Regards,

    Ashwin

  • Posted 15 April 2020, 2:07 am EST

    Hi Ashwin

    But in my case if i am setting the max width, horizontal scroll bar is appearing but it is making the above part of wijmo flexgrid ( for me plus icon and add employee and “select the column that u want to use” text) also scroll horizontally in addition to wijmo flexgrid …

    Please refer the screenshot provided.

    Select the columns that you want to use in your new batch.
    Delete
    ADD EMPLOYEE
    {{ cell.row.index + 1 }} <wj-flex-grid-column *ngFor="let wijmoHeader of wijmoHeaders" [header]="wijmoHeader.data.m_heading" [binding]="wijmoHeader.columnOptions.binding" [isReadOnly]="wijmoHeader.columnOptions.isReadOnly" [visible]="wijmoHeader.columnOptions.visible" [allowDragging]="wijmoHeader.data.m_fieldCode > 4 ? true : false"

    .batch-employee-grid {

    height: auto;

    max-height: 400px;

    text-align: left;

    width: auto;

    max-width: 800px;

    }

  • Posted 15 April 2020, 2:09 am EST - Updated 3 October 2022, 4:34 pm EST

  • Posted 16 April 2020, 12:39 am EST

    Hi,

    I tried to replicate the issue by mimicking your sample using the code snippet provided, but I was unable to replicate:

    https://stackblitz.com/edit/angular-wgnqst

    Can you modify the sample accordingly so that it replicates the issue?

    Also, change the CSS selector of the batch-employee-grid to:

    .batch-employee-grid.wj-flexgrid
    

    and try it again.

    ~regards

  • Posted 16 April 2020, 1:23 am EST

    Hi Ashwin

    The replicated code in stackblitz is correct… what i am trying to achieve from this …

    The upper part like ( plus icon and add employee and “select the column that u want to use” text) should remain as it is even if we scroll horizontally.

    Only the wijmoflexgrid can be scrolled horizontally not the whole part like (plus icon and add employee and “select the column that u want to use” text)…

    So the upper part should remain fixed and only the flexgrid can be horizontally scrolled.

    Could you implement the above logic ?

  • Posted 16 April 2020, 11:56 pm EST

    Hi Soumya,

    Setting the width of the FlexGrid is the logic to display the horizontal scrollbar but this should not make the upper part of your web page scrollable.

    That is why I gave you the stackblitz demo so you can modify it so that it replicates your issue similar to your application. If you will be able to replicate the issue in the stackblitz demo, then I can help you with a solution.

    Most likely, the cause of the issue is CSS. You will need to use the browser’s inspect element in the developers console to check whether an overflow property is applied to the upper part of your web page.

    Also, can you provide me a screenshot where the horizontal scrollbar is visible.

    ~regards

  • Posted 17 April 2020, 1:47 am EST

    The stackblitz solution which you provided has the actual replication of my issue.

    So can u modify something in stackblitz CSS part so that the upper part flexgrid is not scrollable even if we scroll wijmoflexgrid.

    That’s the only thing what i need. But i am not able to accomplish even if i am using some overflow property to upper part.

    In stackblitz solution, if you can see when you scroll flexgrid at the same time upper part like add icon and certains texts are also moving on to left and right based on scroll, which i don’t want to occur.

  • Posted 20 April 2020, 6:22 am EST - Updated 3 October 2022, 4:34 pm EST

    Hi Soumya,

    It seems that there is a misunderstanding. In the example that I provided, when we scroll the FlexGrid, only the headers of the grid scroll with it and not the upper part as shown in the screenshot below:

    What I am asking from you is that can you modify the sample so that it replicates your issue?

    Also, can you please provide a video of scrolling the grid at your end because it seems that the scrollbar is not added in the FlexGrid and the whole popup due to which the upper part is also scrolling.

    ~regards

  • Posted 21 April 2020, 1:13 am EST - Updated 3 October 2022, 4:35 pm EST

  • Posted 21 April 2020, 1:16 am EST

    I have added a screenshot of the stackblitz solution which you have already provided. Here the scroll is happening for all the part(flexgrid as well upper Part)

    But the video which you shared , on this scroll is happening only for flexgrid. I want this feature to implement in my component.

    Could you provide the stackblitz code for the video you shared ?

  • Posted 22 April 2020, 12:04 am EST

    Hi Soumya,

    I haven’t changed anything in the stackblitz example. It seems that there is some issue with your browser.

    Can you please try to run the sample on a different browser and also try to disable all the extensions in chrome and run the sample again.

    ~regards

  • Posted 22 April 2020, 12:28 am EST

    Yeah i ran it in SAFARI, but the issue remained same…

    Please Find the screenshot.

    I think you might have changed some logic to display scroll only in flexgrid.

    Otherwise, I am not sure why it is happening even if tried in chrome after resetting all settings.

  • Posted 23 April 2020, 12:56 am EST

    Hi Soumya,

    I have not changed anything in the code. Besides, you and I have the same link, so anything that would change will be reflected at your side too.

    Can you try out the same sample on a different machine which is not a Mac? Also, try to change the settings so that the scrollbar is always displayed by following the link below:

    https://www.nytimes.com/2017/02/02/technology/personaltech/solving-the-case-of-the-disappearing-scroll-bars.html

    and try out the sample again.

    ~regards

  • Posted 23 April 2020, 7:55 am EST

    Thanks Ashwin

    i followed the procedures mentioned in link , Actually the issue was related to scroll in mac …So now it’s resolved.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels