I have two files. KART.dbf and NAMES.dbf (DBFCDX). Every record in KART.dbf has more than one records in NAMES.dbf (1 to N). All of fields is indexed. I run the test1.exe. I can switch the sort order by clicking the headers of first 3 columns. I can not sort 4th column, because its relation field. When I click the header of 4th column, I want to change the XBrowse contents and change the relation file another like view in test2.exe.
How Can I change it in test1.prg like view in test2.prg?
KART.dbf
-------------------
id, Nümeric, AutoID (created by me)
Ref1, Character
Ref2, Character
It has also indexes TAGs called ID, REF1, REF2
NAMES.dbf
--------------------
id, Nümeric, AutoID (created by me)
Kid, Nümeric (Relation field to KART.dbf. It includes id in KART.dbf)
Name, Character
It has also indexes TAGs called ID, KID, NAME
KART.dbf includes data
----------------------------
1, "Ref11", "Ref12"
2, "Ref21", "Ref22"
3, "Ref31", "Ref32"
4, "Ref41", "Ref42"
NAMES.dbf includes data
----------------------------
1, 1, "Albert"
2, 1, "John"
3, 2, "Hakan"
4, 2, "Smith"
5, 1, "Antonio"
6, 1, "Luiz"
7, 3, "Tommy"
8, 3, "Dave"
test1.prg
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "XBrowse.Ch"
REQUEST DBFCDX
PROCEDURE MAIN()
RDDSetDefault( 'DBFCDX' )
USE NAMES NEW EXCLUSIVE
INDEX ON ID TAG ID
INDEX ON KID TAG KID
INDEX ON NAME TAG NAME
SET ORDER TO TAG KID
USE KART NEW EXCLUSIVE
INDEX ON ID TAG ID
INDEX ON REF1 TAG REF1
INDEX ON REF2 TAG REF2
SET ORDER TO TAG ID
SET RELATION TO ID INTO NAMES
GO TOP
DEFINE WINDOW oWnd TITLE "Kart List" FROM 1,5 to 35.2,95
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS 'ID', 'REF1', 'REF2' ;
HEADERS 'ID','REF1','REF2' ;
ALIAS 'KART' ;
AUTOSORT
oBrw:nMarqueeStyle := 5
oBrw:lRecordSelector := .f.
ADD COLUMN TO XBROWSE oBrw AT 4 DATA NAMES->NAME;
HEADER "FIRST NAME OF KART" SIZE 135
oBrw:aCols[4]:bLClickHeader := {|| MMMMM()}
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()
RETURN
PROCEDURE MMMMM()
MsgInfo("I want to change the XBrowse like test2 view")
RETURN
===========================================================
test2.prg
- Code: Select all Expand view
- #include "FiveWin.ch"
#include "XBrowse.Ch"
REQUEST DBFCDX
PROCEDURE MAIN()
RDDSetDefault( 'DBFCDX' )
USE KART NEW EXCLUSIVE
INDEX ON ID TAG ID
INDEX ON REF1 TAG REF1
INDEX ON REF2 TAG REF2
SET ORDER TO TAG ID
USE NAMES NEW EXCLUSIVE
INDEX ON ID TAG ID
INDEX ON KID TAG KID
INDEX ON NAME TAG NAME
SET ORDER TO TAG NAME
SET RELATION TO KID INTO KART
GO TOP
DEFINE WINDOW oWnd TITLE "Kart List (Sorted Name)" FROM 1,5 to 35.2,95
@ 0,0 XBROWSE oBrw OF oWnd ;
COLUMNS 'NAME' ;
HEADERS 'FIRST NAME OF KART' ;
ALIAS 'NAMES' ;
AUTOSORT
oBrw:nMarqueeStyle := 5
oBrw:lRecordSelector := .f.
ADD COLUMN TO XBROWSE oBrw AT 1 DATA KART->ID;
HEADER "ID"
oBrw:aCols[1]:bLClickHeader := {|| MMMMM()}
ADD COLUMN TO XBROWSE oBrw AT 2 DATA KART->REF1;
HEADER "REF1"
oBrw:aCols[2]:bLClickHeader := {|| MMMMM()}
ADD COLUMN TO XBROWSE oBrw AT 3 DATA KART->REF2;
HEADER "REF2"
oBrw:aCols[3]:bLClickHeader := {|| MMMMM()}
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()
RETURN
PROCEDURE MMMMM()
MsgInfo("I want back to change the XBrowse like test1 view")
RETURN
http://www.objekt.com.tr/fwh_test/relation.rar