>*---------------------- Location Section ------------------------ >* Library: Acustomcontrols.vcx >* Class: Grdsorting >* Method: Init() >*----------------------- Usage Section -------------------------- >*) Description: (ideas from message #946490 by Barbara Peisch) >*) > >* Scope: Public >* Parameters: >*$ Usage: >*$ >* Returns: >*--------------------- Maintenance Section ---------------------- >* Change Log: >* CREATED 01/06/2005 - NN >* MODIFIED 01/10/05 - JMW Changed the variable names to >* Hungarian notation. >* MODIFIED 03/11/2005 - NN >*---------------------------------------------------------------- >IF NOT DODEFAULT() > RETURN .f. >ENDIF > >LOCAL loColumn, loControl > >* Delegate header's click to grid's HeaderClick custom method >* and column's textbox DblClick to grid's DblClick > >FOR EACH loColumn IN THIS.COLUMNS > m.loColumn.AddProperty("cOriginalControlSource",m.loColumn.ControlSource) > FOR EACH loControl IN loColumn.CONTROLS > IF UPPER(loControl.BASECLASS) = "HEADER" > BINDEVENT(loControl,"Click",THIS,"HeaderClick") > m.loControl.AddProperty("CurrentTag","") && Adds CurrentTag property > IF this.lCreateIndexes && Adds indexes on the fly > this.CreateTag (m.loControl) > endif > ELSE > IF UPPER(loControl.BASECLASS) = "TEXTBOX" > BINDEVENT(loControl,"DblClick",THIS,"DblClick") > ENDIF > ENDIF > ENDFOR >ENDFOR > >IF this.lManualHighlight > this.SetAll("DynamicBackColor","iif(recno(this.RecordSource)=this.nRecno,this.HighlightBackColor,this.BackColor)", "Column") > this.SetAll("DynamicForeColor","iif(recno(this.RecordSource)=this.nRecno,this.HighlightForeColor,this.ForeColor)", "Column") > this.HighlightStyle = 0 >ENDIF > >IF this.lSaveGridProperties > this.SaveGridProperties() >ENDIF >>
>local loCalledBy && as Object > >aevents[aCurEvent,0] >loCalledBy = aCurEvent[1] && should be a Header object > >if vartype(m.loCalledBy)= "O" and not empty(m.loCalledBy.parent.cOriginalControlSource) > local lcOrder, lcRecSource, llDirection > lcRecSource = this.recordsource > llDirection = this.lAscending > > lcOrder = order(m.lcRecSource) && Saves current tag > this.SetOrder(m.loCalledBy.parent.cOriginalControlSource, m.loCalledBy.CurrentTag) > if this.lShowSortingArrows >* Check, if we changed the order > if not order(m.lcRecSource)== m.lcOrder or m.llDirection <> this.lAscending >** Clear the picture of the previously sorted column > m.loCalledBy.CurrentTag = this.cTagName > this.ClearHeaderPictures() > this.SetHeaderPicture(m.loCalledBy) > endif > endif >endif >this.mousepointer = 0 >>