Hi all,
sorry for the beginner level question:
I have a data grid that is basically an index to populate other fields/data grids on a card.
When the user clicks on a the index data grid, a mouseUp handler in the behaviour script populates everything else.
So far, so good, everything works as expected.
The problem is restarting the app; no line in the index data grid is highlighted and often the information in the other fields/data grids is the previously held information, when ideally i'd like it to be the first index in the index data grid and the populated data to correspond to this.
I can set the dgHilitedLines of group "indexDataGrid" to 1 and the first line is indeed highlighted.
However the function to populate the card data (normally in the mouseUp handler of the behaviour script) won't run and sending/dispatching mouseUp to the index data grid does nothing, so although the line changes, the data in the card does not update.
Is there a way to programmatically select a line and trigger a mouseUp event for a line in the data grid?
[SOLVED] Programmatically trigger a mouseUp in a data grid?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
[SOLVED] Programmatically trigger a mouseUp in a data grid?
Last edited by stam on Tue Oct 20, 2020 2:01 am, edited 1 time in total.
Re: Programmatically trigger a mouseUp in a data grid?
As an aside, i also experimented adding a selectionChanged handler to the data grid. This works the same as the mouseUp handler in the DG's behaviour script (except now it triggers when moving the selection with arrow keys, which is prefereble i guess).
But i still can't trigger this by setting the dgHilitedLines property of the data grid...
Any advice would be most welcome...
But i still can't trigger this by setting the dgHilitedLines property of the data grid...
Any advice would be most welcome...
Re: Programmatically trigger a mouseUp in a data grid?
I would put the handler that does the populating of other fields in the card script:
Then in the mouseUp of the dataGrid just:
And at openCard or wherever you initialize the app when opening it, you just do:
to get it to select the first line AND populate the fields with it.
Would that do what you want to achieve?
Code: Select all
command displayData pLine
set the dgHilitedLines of group "YourDataGrid" to pLine -- This is redundant when clicking in the dg, but covers the automation case
put the dgDataOfLine[pLine] of group "YourDataGrid" into tDataA
put tDataA["theColumnYouWant"] into fld "theFieldWhereItGoes"
-- etc, for all relevant fields
end displayData
Code: Select all
on mouseUp
put the dgHilitedLines of me into tLine
displayData tLine
end mouseUp
Code: Select all
displayData 1
Would that do what you want to achieve?
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
Re: Programmatically trigger a mouseUp in a data grid?
Thanks Andy, that's very helpful...
I had worked around it just now actually - the selectionChanged handler would actually fire but i hadn't provided current and previous indexes as parameters so it did nothing
so now my code is located in the data grid's script rather than it's behaviour script:
you make a good point about separating the populating the other fields from the behaviour script -- that's what happens when you code at 3 am...
But back to my original question (not really relevant any more but more for my curiosity) - can you dispatch a mouseUp event to the script of a data grid?
I had worked around it just now actually - the selectionChanged handler would actually fire but i hadn't provided current and previous indexes as parameters so it did nothing

so now my code is located in the data grid's script rather than it's behaviour script:
Code: Select all
put the dgHilitedIndex of group "indexDataGrid" into tOldIndex
set the dgHilitedLine of group "indexDataGrid" to 1
put the dgHilitedIndex of group "indexDataGrid" into tNewIndex
dispatch "selectionChanged" to group "indexDataGrid" with tNewIndex,tOldIndex
But back to my original question (not really relevant any more but more for my curiosity) - can you dispatch a mouseUp event to the script of a data grid?
Re: Programmatically trigger a mouseUp in a data grid?
To the datagrid as a whole, yes. If you've added a mouseUp handler to its script. To simulate a mouseclick on a specific row, I guess you'd have to dispatch the mouseUp to the row group of the dg, for the behaviour script to pick it up. (Someone better than me at the inner workings of datagrids may have a better answer.) But as mentioned above, I would opt for a solution that gives more flexible control of both action and view update, adapting to the situation.
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com