Grid objects problems/questions

Hi everyone. I've just started using Grids in VFP9.

I am trying to setup a grid which will collect info about an order.
The record source of the grid changes depending on the user. I use the temporary table in the users 'home' folder in order not to conflict with other users.

Here are my questions:
- First, what is the best way to have a temporary file used in my form: Do I add the table to the dataenvironment at runtime Do I issue 'USE' command at form's init Basically I need to open a file which its name is not static but a variable.
- How do I implement something like "Calculated fields" in old browse When the user enters an item #, I need to populate a field which will contain the number of items in stock. I don't want this column to be bound to any table field because it's just a calculated field.
- I've changed one of the columns to have a checkmark instead of a textbox. Does it have to be bound to a table field Basically I want the user to be able to select multiple items in the grid.

Thanks.



Answer this question

Grid objects problems/questions

  • Jeff King

    Thank you all. I think you may see more posting here by me. Thanks again.

    The Cursor option is not really a solution. The temporary data entry for an invoice needs to exist after files are closed. The user may exit the invoice form after he entered a dozen items, and have it still there.

    Basically I nee to open a file which is called tmpinv and it resids in the users OWN directory.
    But I think I can manage this now using commands to just add the table to the dataenvironment.

    Thanks,
    Aleniko

  • SOTN

    How are you getting the data from your temporary tables to the actual tables

    The whole idea of buffering is to make it possible for several people to edit the same table at the same time. Try reading the topic "Buffering Data" in the Help file. The basic idea is that when a table is buffered, the user is working on a temporary copy, and when you issue TableUpdate(), the data is saved from that copy to the original table. You have various ways to handle conflict resolution (multiple users changing the same record).

    Tamar

  • Linefeed

    Cursor is still a solution IMHO. If it needs to exist after the form closed then form could have default datasession or that form could pack it into an object and save to a variable (when needed cursor could be created again from that object).
    If you would like a table then you could create a unique tablename:

    lcTableName = forcepath(sys(2015)+'.dbf', sys(2023))

  • SPotam

    Cetin;

    I tried to find a way to Email you directly and cuoldn't find one. If possible, I'd like to contact you directly. My Email address is newal@rugwho.com

    Thanks,
    Aleniko

  • Yomi

    -If you are comfortable with temporary tables then use a cursor instead. You could create the cursor in form load or init (both fire after DE.opentables). Making it a cursor you would have a static name for your temporary 'table' while its actual name is generated by VFP itself. Basically the only difference between a cursor and a table is that the cursor's naming on disk and cleanup (erasing when done) is handled by VFP and it is gone when closed. All other operations available for a table is practically available to cursor (with some exceptions like if you use "alter table" you shouldn't have long field names, cannot pass session boundaries, no offline ability... but these are not a show stopper IMHO).
    You create,populate,index,bind to grid,modify etc. When you close it it's gone. So if you use a cursor do whatever update you would do to your base tables before closing it (again unlike a table its file on disk automatically deleted as soon as you close).
    -Calculated fields are not much different from old browse. Write it as a controlsource of a column with parentheses around expression. ie:

    thisform.myGrid.myColumnX.Controlsource = "( myCursor.Qty * myCursor.Price )"
    thisform.myGrid.myColumnY.Controlsource = ;
      "( thisform.MyStockControlClassObject.GetStockBalance( myCursor.ProductID ) )"

    You would need adjust columncount of grid to accomodate your new calculated columns. There are many ways to do it. A simple one is to use Grid.AddColumn().

    -In theory no but in practice yes (managing unbound data might be a nightmare for the coder-depends). Bind grid columns (like browse) to a table or cursor field. Using a cursor you could simply have such a field like "lSelected L" and make it the controlsource of that column.  Since it's simply a field of a cursor it wouldn't harm and would be much easier to handle.

  • nelson_r

      <<First, what is the best way to have a temporary file used in my form: Do I add the table to the dataenvironment at runtime Do I issue 'USE' command at form's init Basically I need to open a file which its name is not static but a variable. >>

    Don't. Use a view or just work with buffering instead. In VFP , there's very little reason ever to create temporary tables.

    Tamar

  • Hrishikesh Biniwale

    Tamar;

    I'm not sure how I can do this with buffering My current Foxpro2.6 system uses dbf files that are in every user's home folder in order to collect temporary data entry. For example, if I want to collect items for an invoice, I would use the tmpinv.dbf file that is in the user's \usr\tamar folder. This way a few users can enter invoices simultanously.
    Not sure how I would do this in VFP with concepts like DE and buffering

    Aleniko

  • Grid objects problems/questions