Board index » delphi » How to prevent record from showing in TDBgrid?

How to prevent record from showing in TDBgrid?

Is there anyway to do the following (without using SQL select)?

I have a DBF table with a flag field.  If a condition in the field is
true, then this record should _not_ display in a TDBgrid.  The flag is
date sensitive, so if the date is changed then the record may be
displayed.  I don't want to have to do an SQL select every time the
date is changed, because (1) it is too slow compared to the table which
is already open, and (2) I need the ability to have many indexes
rapidly selectable, and toggle the order state of the table.

I've tried not drawing the text by using OnDrawDataCell, but that just
leaves a blank line in my grid.  I'd even be willing to settle for
drawing the data in a "grayed" color, though that wouldn't be my first
choice, but haven't had much luck changing the color of a single record
in the grid either.

Any suggestions much appreciated. Thanks.

--
David Dice
Technologies Facilitator, Carlton Comprehensive High School
dd...@paschools.pa.sk.ca
http://pasd2.paschools.pa.sk.ca

 

Re:How to prevent record from showing in TDBgrid?


Quote
dd...@paschools.pa.sk.ca (David Dice) wrote:
>I have a DBF table with a flag field.  If a condition in the field is
>true, then this record should _not_ display in a TDBgrid.  The flag is
>date sensitive, so if the date is changed then the record may be
>displayed.  I don't want to have to do an SQL select every time the
>date is changed, because (1) it is too slow compared to the table which
>is already open, and (2) I need the ability to have many indexes
>rapidly selectable, and toggle the order state of the table.

use a dbase conditional index.  
  e.g. index on surname+firstname+city for BooleanField.

If the data is excluded from the index then it will be excluded from
the record set.

Quote
>I've tried not drawing the text by using OnDrawDataCell, but that just
>leaves a blank line in my grid.  I'd even be willing to settle for
>drawing the data in a "grayed" color, though that wouldn't be my first
>choice, but haven't had much luck changing the color of a single record
>in the grid either.

Yuck!  Better to tackle it from a data set perspective.

Cheers
Wade

Re:How to prevent record from showing in TDBgrid?


Hi,

Could you use two seperate grids? One showing one view of the data and
the other showing the other view. You could then hide and show the
grids as you needed to.

Or, you could hide your current grid and cycle through it picking the
records that you wanted to display. Then take those records and move
them into another grid that the user would interact with.

Hope these ideas spark ideas,
Allen

Quote
dd...@paschools.pa.sk.ca (David Dice) wrote:
>Is there anyway to do the following (without using SQL select)?
>I have a DBF table with a flag field.  If a condition in the field is
>true, then this record should _not_ display in a TDBgrid.  The flag is
>date sensitive, so if the date is changed then the record may be
>displayed.  I don't want to have to do an SQL select every time the
>date is changed, because (1) it is too slow compared to the table which
>is already open, and (2) I need the ability to have many indexes
>rapidly selectable, and toggle the order state of the table.
>I've tried not drawing the text by using OnDrawDataCell, but that just
>leaves a blank line in my grid.  I'd even be willing to settle for
>drawing the data in a "grayed" color, though that wouldn't be my first
>choice, but haven't had much luck changing the color of a single record
>in the grid either.
>Any suggestions much appreciated. Thanks.
>--
>David Dice
>Technologies Facilitator, Carlton Comprehensive High School
>dd...@paschools.pa.sk.ca
>http://pasd2.paschools.pa.sk.ca

Re:How to prevent record from showing in TDBgrid?


[snip]
Quote

>use a dbase conditional index.  
>  e.g. index on surname+firstname+city for BooleanField.

I can't see how this could work, because the field that is being used
is essentially a date (actually a number from 1 to 12, representing the
month).

Essentially what I have is this:
Student has dropped a class at a certain time.  If records are examined
with date set before that time, then his records should show up.  If
the date is set after that time, then they should not.  Note that I
don't want to actually delete the data, just not show it.  The data
isn't indexed on this field at all, or I'd just do a setrange.

Maybe that is the only way around this.  Can you do a setrange on an
index that isn't the controlling index?  If not, then this won't work
either, as I want the data displayed by a totally different index.

--
David Dice
Technologies Facilitator, Carlton Comprehensive High School
dd...@paschools.pa.sk.ca
http://pasd2.paschools.pa.sk.ca

Re:How to prevent record from showing in TDBgrid?


Infopower's wwDBGrid by WollToWoll has a filter property.  It would do the
type of simple filtering that you need.

Tom

Other Threads