WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

COMCONTROL
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

TrueDBGrid Control Sort Issues


Question:

In an attempt to embarrass myself again I thought I would post this and see if anyone could tell me what is going wrong...

If use this method for an event and put the code below from the SubRoutine in the DialogCallback Case statement, uncommenting the first line, all my rows disappear from the grid except for the first line when I click on the column header to sort:

DialogObject(TGR_Handle,co_TGR_grid,dlgobject_addevent,"HeadClick",g_HeadClick)

If use this method for an event then it works as expected:

ObjectEventAdd(grid,"HeadClick","Get_HeadClick")

#DefineSubRoutine Get_HeadClick(col_num)

; col_num = DEInfo.Parameters(1).Value
gname = grid.Columns(col_num).DataField
gtext = grid.Columns(col_num).Text
Message(DEInfo,StrCat("g_HeadClick",@CRLF,col_num,@CRLF,grid.Columns.Count,@CRLF,gname,@CRLF,gtext))
If IsDefined(%gname%_sort_ord) Then
If %gname%_sort_ord == "ASC" Then
%gname%_sort_ord = "DESC"
myREC.Sort = "%gname% DESC"
Else
%gname%_sort_ord = "ASC"
myREC.Sort = "%gname% ASC"
EndIf
Else
myREC.Sort = "%gname% ASC"
%gname%_sort_ord = "ASC"
EndIf

#EndSubRoutine
There may be some Sort property I haven't found yet. This thing has oodles of Methods and Properties and I'm still working through them. Some things that I think would be easy are complicated (or I haven't found the right thing yet) and others are handled under Properties that seem unrelated.

The whole sort question aside I was curious why the exact same code produces different results depending on the approach taken.

Here is a code snippet of the COM EVENT:

Case msg_comevent ; ComEvent
Switch(DEInfo.Identifier)
Case g_HeadClick
col_num = DEInfo.Parameters(1).Value
gname = grid.Columns(col_num).DataField
gtext = grid.Columns(col_num).Text
Message(DEInfo,StrCat("g_HeadClick",@CRLF,col_num,@CRLF,grid.Columns.Count,@CRLF,gname,@CRLF,gtext))
If IsDefined(%gname%_sort_ord) Then
If %gname%_sort_ord == "ASC" Then
%gname%_sort_ord = "DESC"
myREC.Sort = "%gname% DESC"
Else
%gname%_sort_ord = "ASC"
myREC.Sort = "%gname% ASC"
EndIf
Else
myREC.Sort = "%gname% ASC"
%gname%_sort_ord = "ASC"
EndIf
Break

Answer:

Have you tried the dialog callback version with only the "headclick" event added?

The dialog function tells the control to freeze other events while it is processing an event. This is the only significant difference between ObjectEventAdd and DialogObject based events.

The control decides what it wants to do when the container tells it to freeze events so there is no way to predict the behavior. In most cases the control just waits until the container is ready, but in this case the control may decide to discard any processing that has been tagged to produce an event. (Note that this explanation also assumes that the line myREC.Sort actually triggers the sort.)

I have seen this behavior with other controls that have a sort feature. If is is the case then the only alternative is to use an external subroutine to handle the "headclick" event.

Keep in mind that this is just an educated guess on my part because I have not tested the idea with this particular control, so there may be another explanation.

User Reply:

Yes. That has been my approach. I have only added the one event using one method or the other and the results have always been consistent. I don't mind using the external routine...for many things I would probably call one anyway. I was just curious about the behavior and thought you might like to know in case it turned out to be a WB issue.

I am happy to continue trying things to see if we can find out what is causing this behavior but I am also happy to drop it if you are confident it is an ADO or GridControl issue. I can make it do what I need so either approach is fine.

Answer:

Based on what has been presented, I see no indications that this is anything other than an issue relating to the controls implementation. In other words, there is no indication that this a WB bug.

User Reply:

Okie Dokie. Good enough for me. Thanks.

Answer:

I was able to confirm that event freezing is the reason that the "TrueOleDBGrid80.TDBGrid" control does not finish reloading the grid display. I don't know why the control developers chose to have the grid behave this way but I am sure they have a reason. The only known solution is to handle this event with a separate event handling routine.

Other than this inconvenience the TrueGrid control appears to be a nice, feature rich tool. Of course, your mileage may very.


Article ID:   W16933
File Created: 2007:07:03:14:27:06
Last Updated: 2007:07:03:14:27:06