Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outsider Project - Generic Find for a Grid 1

Status
Not open for further replies.

benman

Programmer
May 3, 2006
35
HK
Hi All:

Currently I am developing a VFP system on my own from scratch, with a layout familiar to everyone.

What has been developed are:
1) selector
6 sections x 6 subsections, selecting 36 pages of view/filter combinations.
2) a grid control displaying database for browsing.
3) double click the grid record to display a form for database maintenance, with ColumnCount being -1, and memberclass pointing to predefined Column library in a prg.
What I want to do now is:
Generic Find bar for the Grid - A comparable funtion MOutLook

The CtnFindBar is a Container where lives a label, a textbox and 2 command buttons.

Any comment/advice to enlighten the project to move forward, inclusive design, beauty & code ...

02.jpg
 
MOutLook's Find check on Character Field & Memo Field. It can find inside the field content also.

VFP got "set filter to", without additive.

very difficult to accomplish here. HELP!
 

Benman,

First thing you need to do is to define how you want the Find to work. Do you want it to search all the columns in the grid, or only the selected one? Do you want it do substring searches, or "starts with" searches, or only exact matches? What about case sensitivity?

After you've thought about those issues, you need to decide what you want to do with the search results. Do you want to highlight the first matching record (which implies you also have a Find Next button)? Or filter the grid to show just the matching records?

Note that I'm not asking you to give me the answers to those questions. I'm simply saying that you need to make those decisions before you go any further.

As far as the programming is concerned, probably the best approach will be to programmatically create either a SELECT or SET FILTER TO, then to macro-execute it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike :

Find should work like this :

1) It should fit with the settings: Current View provided dataenvironment with fields assortment. Filter underneath provided predefined filtering conditions.

2) cText.value should compare with each columns' text's value whose type is a character. Grid's Text's value whose are of Date/Numeric shall be ignored. Logical shall not be compared with.

3) It should be case-insensitive & sub-string search mentioned.

4) Find is additive filtering on what has been filtered. It makes sense to the user.

5) Grid shall display records meeting new filtering condition with a light click on Find Now button displayed above.

6) Highlight on case-insensitive matches is not necessary for a clean browse drop.

Benman
 

Benman,

I won't try to write the whole code for you, but it should go something like this:

- Set lcFilter to ""

- Loop through all the columns in the grid

- For each column, find the corresponding field in the underlying table (check the column's ControlSource)

- Is this a character or memo field (use VARTYPE() to check this)?

- If yes, add a string to lcFilter. The string should be something like " AT(UPPER(ALLTRIM(.cText.Value)), UPPER(ALLTRIM(EVAL(the field name)) > 0 ) AND "

- On completion of the looping through the columns, do this:

lcOldFitler = SET("filter")
IF NOT EMPTY(lcOldFilter)
lcFilter = lcOldFilter + " AND " + lcFilter
ENDIF
* Add code here to remove final " AND " from lcFilter
SET FILTER TO lcFilter
GO RECNO() && move record pointer in order to apply the filter

Come to think of it, you'll have to save lcOldFilter somewhere (probaby a form property) so that you can restore it in your Clear button.

This is all of the top of my head.I don't claim it will work perfectly, but is should start you in the right direction.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top