Page 1 of 1

Detect Horizontal Scrolling in DataGrid

Posted: Mon Aug 22, 2011 1:07 am
by dickey
Hello All,

I have a group containing fields I use to filter a DataGrid object and wish to scroll them simultaneously when a user scrolls horizontally in the DataGrid.

So within the script of the DataGrid I wished to intercept the horizontal scrolling event, then similarly scroll the filter field group before passing the horizontal scroll event in the DataGrid.

I figured in the script of the DataGrid something like:

Code: Select all

setprop dgHScroll [pValue]
   set the hScroll of group "grpFilter" to pValue
   pass dgHScroll
end dgHScroll
, but that isn't it.

I can manually do it from a button using:

Code: Select all

  get the dgHScroll of group "DataGrid 1"
  put it into tHScroll
  set the hScroll of group "grpFilter" to tHScroll
, which proves the concept - however I need intercept the event when it happens.

Any assistance greatly appreciated.

Kind regards, Andrew

Re: Detect Horizontal Scrolling in DataGrid

Posted: Tue Aug 23, 2011 1:39 am
by Steve Denney
Hi Andrew,
Not quite sure what you're after, but i'm thinking it's something like this:

Code: Select all

on scrollBarDrag pValue
   set the hScroll of group "grpFilter" to pValue
end scrollBarDrag
Look up scrollBarDrag in the dictionary. It gets sent to flds, grps, sbs when they're scrolled. You might need a pass scrollBarDrag with the above if you want the scrolled fld/grp (the one that sends the message) to scroll--not sure about that.

scrollBarDrag newPos

...is a message sent by the scrolled object so you can use it to do whatever you want i.e.

Code: Select all

on scrollBarDrag newPos
   doStuff newPos
end scrollBarDrag
where doStuff is a function or procedure defined higher up the message path.
Steve

Re: Detect Horizontal Scrolling in DataGrid

Posted: Tue Aug 23, 2011 2:30 am
by dickey
Hello all,

A solution provided by Zryip The Slug via the LiveCode Developer List:

To intercept horizontal scrolling in the DataGrid and to similarly scroll another group, in the script of the DataGrid add the following handler:

Code: Select all

on dgScrollbarDragH pScrollValue
  set the hScroll of group "grpFilter" to pScrollValue
  pass dgScrollBarDragH
end dgScrollBarDragH
I hope that assists someone else.

Kind regards, Andrew

Re: Detect Horizontal Scrolling in DataGrid

Posted: Tue Aug 23, 2011 2:37 am
by dickey
Thanks Steve,

I did try that, however it seems the DataGrid has it's own custom properties in respect of scrollbars.

Zryip corrected my earlier attempt at coding against the datagrid's custom properties.

Thanks again for posting. Steve.

Kind regards, Andrew

Re: Detect Horizontal Scrolling in DataGrid

Posted: Tue Aug 23, 2011 4:54 am
by Steve Denney
Apologies Andrew, I didn't know what a datagrid was (just looked it up). In fact I've fairly recently made a database app from scratch with similarly scroll-able, user-resizeable column flds--sheesh, I wish I'd known. (At least I can set the scrollwidths).
Steve