Page 1 of 1

dispatch mouseup to dgDataControlOfIndex error

Posted: Tue Dec 31, 2013 12:29 am
by Martin Koob
I want to be able to simulate clicking on a row of a datagrid that is not displayed by dispatching "mouseUP"

If I try to dispatch a mouseup to a dataGrid row that is not displayed with the following line

Code: Select all

 dispatch "mouseup" to the dgDataControlOfIndex[ProjectsIndex] of group "projects" 
I get the following error. "Type Chunk: error in object expression"

I think the error is due to the fact that the control is not drawn yet.
The error does not happen if the row is displayed.

I tried setting the 'cache controls' of the dataGrid to true and that avoids the error.

I was wondering if there was another way to avoid error by scrolling to the index first. I tried the following code which is based on code in a livecode lesson:http://lessons.runrev.com/s/lessons/m/d ... -grid-form

Code: Select all

on scrollToDgRow theIndex
   put the dgRectOfIndex[theIndex] of group "projects" into theControlRect
   put the rect of group "Projects" into theGridRect
   put item 2 of theGridRect - item 2 of theControlRect into theOffset
   set the dgVScroll of group "Projects" to the dgVScroll of group "Projects" - theOffset
end scrollToDgRow
This will only scroll to displayed controls unless 'cache controls' are set to true.

I read setting cache controls to true can cause poor performance of the dataGrid.
Is there a way to access indexes of the dataGrid that are not displayed without using cache controls?

Thanks.

Martin

Re: dispatch mouseup to dgDataControlOfIndex error

Posted: Wed Jan 01, 2014 1:42 pm
by Klaus
Hi Martin,

do you really need a "visual" feedback/clue?
Can't you just use something like:
...
put the dgdata of grp "your dg here" into tData
put tData[ProjectsIndex] into tDataOfStillHiddenRow
## Now do something with that array -> tDataOfStillHiddenRow
...
Just quick guess...


Best and a happy 2014 :D

Klaus

Re: dispatch mouseup to dgDataControlOfIndex error

Posted: Sun Jan 12, 2014 11:38 pm
by Zryip TheSlug
Hi Martin,

When cache is turned to off, a row as only an existence in a datagrid if the row is displayed, so it is not possible to refer to the row controls.

For scrolling to the row and have it displayed in the datagrid you can use:

Code: Select all

ScrollIndexIntoView tTheIndex
where tTheIndex is the row index.

But I'm not sure of your final goal. Why do you have the need to select a not displayed row. Data retrieving?