Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Need for fixed column on the left when horizontal scrolling
Wed, Dec 12 2018 5:30 PMPermanent Link

erickengelke

Avatar


I have a client that needs to keep the left most column (ie. the name of the row) visible when I scroll horizontally.
I don't think EWB has the concept of a fixed Column like that.  I imagine others will want this feature too.

I'm thinking of emulating the effect using Visibility of columns to make intermediate ones disappear, but that's a pretty kludgy workaround.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Thu, Dec 13 2018 12:06 PMPermanent Link

Eivind

erickengelke wrote:


<<<<<<I have a client that needs to keep the left most column (ie. the name of the row) visible when I scroll horizontally.
I don't think EWB has the concept of a fixed Column like that.  I imagine others will want this feature too.>>>>

Funny you would mention this now as I'm also in need of the exact same thing right now. I have experimented by using two grids, but I cannot get the vertical scrolling to synchronize correctly. The OnScroll Event is not called when the mouse scrolls vertically and the ScrollTop Value of the grid appears to always be 0. Hopefully someone could enlighten us how to achieve this.
Thu, Dec 13 2018 2:39 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eivind,

<< The OnScroll Event is not called when the mouse scrolls vertically and the ScrollTop Value of the grid appears to always be 0. >>

When you scroll a grid with the mouse (or by using the scrollbars), you *aren't* scrolling the actual selected row.  With grids, the OnScroll event only gets fired when the active row changes in some way, it does *not* behave like a scrolling panel or other type of container.

If you want to synch a data-bound grid with some other dataset/control, you should use the OnRowChanged event for the grid or dataset in order to do so.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Dec 14 2018 4:52 AMPermanent Link

Eivind

<<<<<<When you scroll a grid with the mouse (or by using the scrollbars), you *aren't* scrolling the actual selected row.  With grids, the OnScroll event only gets fired when the active row changes in some way, it does *not* behave like a scrolling panel or other type of container.

If you want to synch a data-bound grid with some other dataset/control, you should use the OnRowChanged event for the grid or dataset in order to do so. >>>>>>>>>>>>>>

Thanks for the info Tim. So to emulate a fixed culumn using two grids, do you see any possibility to sync both current columns selection using OnRowChanged AND the scroll position? Any possible hack to get access to the scroll bars and read / set its position (ScrollTop)?

If not, do you see any other solution on having one fixed column?

Thanks
Eivind
Sun, Dec 16 2018 8:08 AMPermanent Link

D.C.

Hi all,
This code gets one column fixed, but only works when you change the selected column navigating the cells.

Name the first column as colFixed, the others doesn't matter.
Assign this code to the OnEnter event of all grid columns.

procedure TForm1.GridColumn2Enter(Sender: TObject);
var
  n, VisibleWidth, MaxIndex: integer;
begin
     VisibleWidth:=0;
     for n:=colFixed.Index to Grid1.ColumnCount-1 do
     begin
           if VisibleWidth<Grid1.Width then
           begin
                 VisibleWidth:=VisibleWidth+Grid1.Columns[n].Width;
                 MaxIndex:=n;
           end;
     end;
     if TGridColumn(Sender).Index>MaxIndex then
        colFixed.Index:=colFixed.Index+1;

     if (TGridColumn(Sender).Index=colFixed.Index-1) and (colFixed.Index<>0) then
        colFixed.Index:=colFixed.Index-1;
end;

The code calculates de the index of the rigthmost visible column, and if the current entered column is bigger, it changes the index of the fixed column to get it as the first visible.

I didn't try to make it work with the horizontal scroll bar, I don't know if it's possible.

Attached is a sample project.
Regards
Diego





Attachments: FixedCol.zip
Thu, Dec 20 2018 1:57 AMPermanent Link

Eivind

<<<<<I didn't try to make it work with the horizontal scroll bar, I don't know if it's possible>>>>>

@D.C. Thanks for your project. Yea, with Horizontal Scroll bar is really where it would be needed as I have a long horizontal scroll able grid.

Erik. Did you test further and have come up with anything?




Thu, Dec 20 2018 10:43 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eivind,

<< Thanks for the info Tim. So to emulate a fixed culumn using two grids, do you see any possibility to sync both current columns selection using OnRowChanged AND the scroll position? Any possible hack to get access to the scroll bars and read / set its position (ScrollTop)? >>

Are both of the grids attached to the same dataset ?  If so, then you shouldn't need to do anything else.  Or is the issue that the row offset *within* the visible rows gets out of synch between the two ?

<< If not, do you see any other solution on having one fixed column? >>

Let me see what's involved.  This has been "on the list" for some time, so a lot of people want it.  The main issue that I see is that the grid's control interface(s) will probably require some modifications, and I try to avoid that because a lot of customers customize the control interfaces.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Dec 21 2018 5:10 AMPermanent Link

Eivind

<<<<<<<<<<Are both of the grids attached to the same dataset ?  If so, then you shouldn't need to do anything else.  Or is the issue that the row offset *within* the visible rows gets out of synch between the two ?>>>>>>>>>

@Tim. Yes, the two grids will be connected to the same dataset. Its correct as you mention that the two grids gets out of synch within the visible rows. If I had a way to synch them as well, I could simulate one or more fixed columns.

<<<<<Let me see what's involved.  This has been "on the list" for some time, so a lot of people want it.  The main issue that I see is that the grid's control interface(s) will probably require some modifications, and I try to avoid that because a lot of customers customize the control interfaces.>>>>>

Thanks for looking into this matter weather this involves interface changes or not. I'm one of the many I guess that modifies the control interface, but would be happy to "re-modify" if new functionality comes to light.

Thanks
Eivind
Thu, Jan 3 2019 5:32 AMPermanent Link

Eivind

@Erik

Did you manage to get this to work? I'm still unable to come up with a solution that works for me. Tried using two grids but I cannot get them to synch the scrolling.
Image