Subject Re: grid problem
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 16 Dec 2017 15:55:08 +0200
Newsgroups dbase.getting-started

On 2017-12-16 12:48 PM, Charlie wrote:
> Hi Akshat.. I'll bet that is it.  I don't know how to use beginedit() and beginappend().  I think I encountered this before but can't remember how it was resolved.  Here is the sql code:  this.CONVSHOP1 = new QUERY(this)
>     with (this.CONVSHOP1)
>        left = 56.0
>        database = form.train1
>        sql = "select * from CONVSHOP order by location"
>        active = true
>     endwith
> Thanks for your help!!!

There's your problem. :-)  The moment you use an ORDER BY clause the
rowset becomes read-only.  There is, however, one exception and that is
where there is only one field in the ORDER BY clause AND there is a
simple index on the field.  The index doesn't have to be active, it just
has to be there.

To fix your problem simply create an index.

use convshop exclusive
index on location tag location
use

You don't need to do anything else.

This won't work if you have more than one field in the ORDER BY clause.
If you need an editable rowset under those conditions you will need to
create the index and then assign it to the rowset's indexname property.

I've never liked editing in an index.  Experience has shown it is too
easy to make mistakes.  I prefer to use the grid, with it's allowEditing
property set false, to display the data but I use entryfields for
editing and appending.

If you datalink the fields to the rowset the the contents will change as
you select a new record in the grid.

If you add buttons to your form for Add, Edit, Abandon and Save you
would use form.queryname.rowset.beginAppend(),
form.queryname.rowset.beginAppend(), form.queryname.rowset.abandon(),
form.queryname.rowset.save() in their respective onClick event handlers.

If you only have one rowset to worry about you don't even need to do any
programming.  Execute the following in the Command Panel before you open
the form designer.

set procedure to :formcontrols:databuttons.cc

This will add a Data Buttons tab to the Component Palette and you can
simply place the buttons you need.  No further programming required as
it is all hidden in the .cc file.

Instead of using individual buttons you could use the Bardataedit
toolbar.  If you place it in the wrong position moving it is a bit
tricky.  Select the bardataedit control in the dropdown list of teh
Inspector.  While holding the control-key down click on each of the
buttons in the toolbar. As each one is selected you will see the four
black "handles" appear.  When the last one has been selected keep the
left mouse button down, release the control-key and drag the toolbar.
Release the mouse button then click anywhere outside the toolbar to
deselect it.

Mervyn.