FoxInCloud
awgrd.recordsource_assign & ColumnCount problem
Gravatar is a globally recognized avatar based on your email address. awgrd.recordsource_assign & ColumnCount problem
  Paul
  All
  Aug 13, 2019 @ 06:13pm

Hi,

awgrd.recordsource_assign contains this code :

IF .T.;
	 and !Empty(m.this.RecordSource); && just added this to fix issue raised by Patrick on 06/19/2012: .RecordSource initially blank and blanked again in code
	 and (Empty(m.RecordSource) or this.wlCntGrdPage and !this.wlCntGrcCSpageCursor); && and .F.
	 and m.this.ColumnCount > 0;
	 and AddProperty(m.this, Textmerge('_aControlSource[<<m.this.ColumnCount>>]'));
	 and AddProperty(m.this, '_ColumnCount', m.this.ColumnCount);
	 and AddProperty(m.this, '_LinkMaster', m.this.LinkMaster);
	 and AddProperty(m.this, '_RelationalExpr', m.this.RelationalExpr);
	 and AddProperty(m.this, '_ChildOrder', m.this.ChildOrder)
		FOR liCol = 1 TO m.this.ColumnCount && ************* CODE CRASHES HERE **************
			this._aControlSource[m.liCol] = m.this.Columns(m.liCol).ControlSource
		ENDFOR
	ENDIF

The problem is that sometimes, even though this.ColumnCount > 0, there are not enough columns defined and the code crashes as indicated above.

(Note that I have removed the .MemberClass setting from the grid that FiC added (previously I did not use it) because it was making grids incredibly slow to initialise; a grid that used to take 1 second to appear might take 2 minutes!!! I suspect something related to VFP trying to find the .prg that holds the column class).

Anyway I have altered the awgrd.recordsource_assign code to cope with this situation and I'm just hoping that this is fine in web mode (I am only testing in lan mode at the moment, haven't gotten to web mode yet).

You may need to change the FiC code to cope with this strange situation...

EDIT :
FYI - I have found that the problem occurs when a cursor, that a column uses as its .controlsource, is recreated and the grid's recordsource is another cursor - the columns based on the recreated cursor are removed and grid.ColumnCount is not altered.
So, I will add this.ColumnCount = 0 prior to setting .recordsource and remove any remaining columns to ensure things are right.

Thanks
Paul

© 1996-2024