Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dang that grid- won't change index order
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00652648
Message ID:
00653187
Views:
22
Here is a terse copy of the header class I use to do this. Only a couple of functions and a couple of properties. The reason I don't use the click event is that it conflicts with the user simply trying to move columns around. Also, I haven't tested to see if it makes a difference, but I refresh the grid before moving the record pointer.

IndOrder will be filled in during the grid init. I don't index or allow ordering on all columns. In some cases it wouldn't really make any sense.

PrevOrder is a property I add to the column itself. It allows me to test whether the user is just moving the column from one place to another.

AllowHeaderClick is another added property (to the form) that allows me to use a standard class but in some situations to disallow any action on clicking a header.

It's not long, not complicated, and (so far), it works.
DEFINE CLASS ColHeader as Header

MClicked = .F.   && in process of a click?
IndOrder = ''    && tag name of index for column

PROCEDURE MouseDown
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF !EMPTY(This.IndOrder)   && ignore empty tags
  IF nButton = 1	&& left button
    This.MClicked = .T.    && now in process of a 'click'.
  ENDIF
Endif
ENDPROC

PROCEDURE MouseUp
LPARAMETERS nButton, nShift, nXCoord, nYCoord
LOCAL lnRecNo

ThisForm.LockScreen = .T.

IF !EMPTY(This.IndOrder)
  * do nothing if right button, if mouseup on some other column, or if column being moved
  IF nButton = 1 AND This.MClicked AND This.Parent.ColumnOrder = This.Parent.PrevOrder
    IF ThisForm.AllowHeaderClick   && form says ok to click header
      lnRecNo = RECNO()            && save record
      * if this index already set, reverse order
      IF ORDER() = UPPER(This.IndOrder)
        IF DESCENDING()
          SET ORDER to TAG (This.IndOrder) ASCENDING
        ELSE
          SET ORDER to TAG (This.IndOrder) DESCENDING
        ENDIF
      ELSE        && otherwise, use ascending
        SET ORDER to tag (This.IndOrder) ASCENDING
      ENDIF
      This.Parent.Parent.Refresh()     && grid refresh
      GOTO lnRecNo                     && get back to where we were
    ENDIF
  ENDIF
ENDIF

** reset all columns' Mclicked to .F.
IF nButton = 1
  FOR lnCount = 1 TO This.Parent.Parent.ColumnCount
    lcHeader = 'This.Parent.Parent.Columns[' + ;
    ALLTRIM(STR(lnCount)) + '].ColHeader1.MClicked = .F.'
    &lcHeader
  ENDFOR
Endif
* set column prevorder
This.Parent.PrevOrder = This.Parent.ColumnOrder

ThisForm.LockScreen = .F.

ENDPROC

ENDDEFINE
>The downloaded example is a complex class created to do this work with a ton of functions that check for mouse movement, double-clicking and so forth. I was looking for a much simpler answer, I guess... Maybe the anser isn't simple!
>
>It just seems to me that the technique I am using is correct- i.e. the data is in the correct sort order when I issue a "Browse" but the data is not refreshed on the grid regardless of my code...
>
>SELECT personel
>SET order to 1
>GO TOP
>WITH this
> .refresh()
>ENDWITH
>
>Is there some function that refreshes the grid object or do I need to look further at "data buffering" and other issues? It just seems that the data is no longer bound to the grid... even though updates to the table are immediately written. Maybe the grid refuses to move?
>
>Thanks!
Previous
Reply
Map
View

Click here to load this message in the networking platform