Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding items in a grid. Slow performance ??
Message
From
28/04/1998 04:08:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/04/1998 13:10:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00095070
Message ID:
00095326
Views:
31
>>>I have a grid in a form to add records in a table. When the user begins adding records the performance is very good; but each time adds new record the execution of the form is slower. When he has append several records, is necesary to close form and reenter in order to have a good performance. ¿Any help on this?
>>Carlos,
>>If performance is getting worse as recco increases, check for any method calling routines that operate on whole table. And for a grid calling activerow is a performance degrader (ie: a column controlsource = this.activerow).
>>cetin
>
>Cetin,
>I have no methods tha operates on whole table, except a sum command that use first a seek one and then sum rest... while. But i think this cannot be the problem cause if you close form and execute it again the performance returns good.
>
> About 'activerow' propertie, i'm using it only in order to save which record we are editing:
>
>m.fila = grid.activerow
>activatecell(grid.activatecell(m.fila, 1)
>
>Maybe this is the problem ??? If yes, How can i write a method that work only when the user moves into another row to ask him to save changes or not ???. I have the cursor with the buffermodeoverride propertie set to 4.
Carlos,
Both could be a cause (especially activerow). For activerow you could use recno() :
m.fila = recno()
...
goto m.fila
For summing I suggest to do the whole sum once and then update the result from controls only that would affect the sum. You could keep a variable, an array or read&write cursor depending on your summed fieldcount and summed set.
* Sum child three fields per parent change + child update
* Method summing at form entry - ie: form.init
select linkfield, ;
    sum(field1) as sum1, ;
    sum(field2) as sum2, ;
    sum(field3) as sum3, ;
    from childtable ;
    group by 1 ;
    where .t. ;
    into cursor tcTemp
use dbf("tcTemp") in 0 again alias tcTotals
use in "tcTemp"
select tcTotals
index on linkfield tag linkfield
* Bind sum showing controlsource to appropriate fields 

* Method controlling parentrec change
* Relation not used taking buffering into account
* AdjustSumRecPointer - custom method
lparameters cLinkKey
seek(cLinkKey, "tcTotals", "LinkField")
* a refresh for controlsource(s) here

* Method controlling sumvalue
* AdjustSumValue - custom method
lparameters cLinkKey, cControlSource, cTotalsFieldName
*cSumChange = orgtotal + (newval - oldval)
nDotPos = rat(".",cControlSource)
cFieldName = substr(cControlSource,nDotPos+1)
cTableName = substr(cControlSource,1,nDotPos-1)
nOldVal = nvl(oldval(cFieldName,cTableName),0)
nNewVal = nvl(eval(cTableName+"."+cFieldName),0)
if !seek(cLinkKey, "tcTotals", "LinkField")
   insert into tcTotals values (cLinkKey, 0, 0, 0)
endif
replace (cTotalsFieldName) with ;
    eval(cTotalsFieldName) + (nNewVal - nOldVal)
* a refresh for controlsource(s) here

* A numeric field effecting sum1 value
* lostfocus
thisform.AdjustSumValue(myParentKeyHere, this.controlsource, "sum1")
Intermediate variables are used for readability. Still advantage would be all summing done once at init then only one sum value is updated. If an array or just one var was used then you would only set new value of it (bound to a control on form would need no refresh at all).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform