Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid controls stuck in 'read-only' mode...
Message
From
29/03/2001 10:14:57
 
 
To
28/03/2001 22:54:31
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00489724
Message ID:
00489858
Views:
9
>Ah, this all makes sense now. If you SELECT into a cursor, the cursor is not editable. Still strikes me as odd behaviour but I guess that's just the way it is.

Anne,

You can easily make the cursor editable. Here's the code...
FUNCTION EDITCURS( tcCursorAlias )
*
*  OVERVIEW:   This routine converts a readonly cursor into a writable
*                   cursor by opening it again.
*
*  PARAMETERS: tcCursorAlias - Alias of the cursor to be converted.  
*                   If omitted the ALIAS() is used.
*
*  RETURNS:    None
*
*  HISTORY:    08/30/1997 (JME)
*
********************************************************************************
LOCAL lnWorkAra, lcTmpDBFName, lcTmpCur, lnCurrArea, lcFilter

*  If a cursor to be converted has not been passed as a parameter, assume it
*  is the current alias.
IF PCOUNT() = 0
    tcCursorAlias = ALIAS()
ENDIF

*  Save the current workarea.
lnCurrArea = SELECT()

*  Make the cursor the current workarea.
SELECT (tcCursorAlias)

*  Get the workarea of the cursor.
lnWorkArea = SELECT(0)

*  Check the type of cursor passed.  If the cursor is 'filtered' (no physical 
*  disk presence), then it can't be opened in another workarea, thus 
*  necessitating that a 'real' cursor be created.  If it is a 'real' cursor,
*  it can be opened in another workarea and edited.
*
*  A 'real' cursor file has a ".tmp" extension.

IF AT( ".TMP", DBF() ) > 0

    *  Reopen the cursor AGAIN in a new workarea to make it editable.
    SELECT 0
	
    *  Get the file name of the cursor
    lcTmpDBFName = DBF(tcCursorAlias)
	
    *  Reopen the file again.  This makes it writable.
    USE (lcTmpDBFName) AGAIN

ELSE
    *  Force it to be a 'real' cursor by issuing a 'WHERE' condition in the 
    *  SQL statement that is NOT optimizable. 4/28/94 (FoxTalk 4/94)

    lcFilter = FILTER()
    IF EMPTY( lcFilter )
        lcFilter = '.T.'
    ELSE
        lcFilter = lcFilter + ' .AND. .T.'
    ENDIF
	
    SELECT * FROM (DBF(tcCursorAlias)) ;
        WHERE &lcFilter ;
    INTO CURSOR lcTmpCur

    *  Get the name of the physical file on disk.
    lcTmpDBFName = DBF('lcTmpCur')

ENDIF

*  Reopen the editable cursor in the original workarea assigning it the 
original alias
USE (lcTmpDBFName) AGAIN IN (lnWorkArea) EXCLUSIVE ALIAS (tcCursorAlias)

*  Close the temporary editable cursor
USE	

*  Reselect the original workarea
SELECT (lnCurrArea)

RETURN

ENDFUNC && EDITCURS()
The problem with using a writable cursor as a grid source, compared to say a view, is that you somehow have to move the changes in the cursor back to the source table(s). For that reason, most developers use either a table or view as the data source of a grid.

Regards,
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform