Hi,
10.2B using a Microsoft DataGridView control with a proBindingSource.
When the user clicks a column I want to sort the query, so on the proBindingSource 'SortRequest' event I fire the method that re-opens the query. Doing this causes the DataGridView to go 'nuts'. Flashes, sometimes crashes the session. Basically it seems the datagrid is stuck in a loop of some sort.
Any ideas? Code that reproduces the issue is attached.
Thanks,
Justin
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/dataGridIssue.zip:550:0]
When the user clicks a column I want to sort the query, so on the
proBindingSource 'SortRequest' event I fire the method that re-opens
the query.
What does this method do?
[update: these ar ethe kinds of replies one makes when (a) it's Monday morning and (b) one replies via email. I just realised you attached the code]
-- peter
Hi Peter,
The relevant stuff are these 2 methods. popDataGrid prepares the query and attaches it to the pbs. bs1_SortRequest assigns a var that determines the sort order then runs popDataGrid. In my actual application I have code that runs popDataGrid many times based on clicks in a treeview without issue, so I'm not sure running it multiple times is the issue...
class:
DEF PRIVATE VAR qttTest AS HANDLE NO-UNDO.
DEF PRIVATE VAR vttTestCurrSort AS CHAR NO-UNDO INIT "ttTest.f1".
METHOD PRIVATE VOID popDataGrid ():
DEF VAR vQuery AS CHAR NO-UNDO.
IF VALID-HANDLE (qttTest) THEN qttTest:QUERY-CLOSE ().
ELSE CREATE QUERY qttTest.
qttTest:SET-BUFFERS(BUFFER ttTest:HANDLE).
ASSIGN vQuery = "FOR EACH ttTest no-lock"
vQuery = vQuery + " BY " + vttTestCurrSort.
qttTest:QUERY-PREPARE (vQuery).
qttTest:QUERY-OPEN().
bs1:HANDLE = qttTest.
END METHOD.
@VisualDesigner.
METHOD PRIVATE VOID bs1_SortRequest( INPUT sender AS System.Object, INPUT args AS Progress.Data.SortRequestEventArgs ):
ASSIGN vttTestCurrSort = "ttTest." + args:FieldName.
IF NOT args:ASCENDING THEN
ASSIGN vttTestCurrSort = vttTestCurrSort + " DESCENDING".
THIS-OBJECT:popDataGrid().
RETURN.
END METHOD.
Interesting. I'd report it to Tech Support .
-- peter
@VisualDesigner.METHOD PRIVATE VOID bs1_SortRequest(INPUT sender AS System.Object, INPUT args AS Progress.Data.SortRequestEventArgs ):ASSIGN vttTestCurrSort = "ttTest." + args:FieldName.
IF NOT args:ASCENDING THENASSIGN vttTestCurrSort = vttTestCurrSort + " DESCENDING".THIS-OBJECT:openQuery().RETURN.END METHOD.
METHOD PRIVATE VOID popDataGrid ():IF VALID-HANDLE (qttTest) THEN qttTest:QUERY-CLOSE ().
ELSE CREATE QUERY qttTest.
qttTest:SET-BUFFERS(BUFFER ttTest:HANDLE).THIS-OBJECT:openQuery().bs1:HANDLE = qttTest.END METHOD.
method private void openQuery ():
DEF VAR vQuery AS CHAR NO-UNDO.
ASSIGN vQuery = "FOR EACH ttTest no-lock"
vQuery = vQuery + " BY " + vttTestCurrSort.
qttTest:QUERY-PREPARE (vQuery).qttTest:QUERY-OPEN().end method.
This doesn't change the fact that the behavior you encountered is weird and should be reported to Support.
Thank you so much for your suggestion! With a little tweaking, I was able to make it work.
However, I was not creating a new query every time. It seems the actual issue was with the query-close() and the re-binding of the query to the prodatasource.
Regardless, it is weird behaviour. I have reported the bug.
Justin
OK an update on the issue. Tech support got back to me and suggested pretty much the same work around as you did.
They did not log it as a bug because they cannot catch what is taking place.
So don't do what I did!
Justin
Tech support got back to me and suggested pretty much the same work around as you did.
They did not log it as a bug because they cannot catch what is taking place.
Maybe Peter or Harvard could help their colleagues to catch the issue...?
OK an update on the issue. Tech support got back to me and suggested
pretty much the same work around as you did.
They did not log it as a bug because they cannot catch what is taking
place.
Did you get a WR number?
-- peter
W/R: W004270061
Justin