Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to keep Grid contents sorted on RecordSource field
Message
De
21/05/2003 12:36:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
21/05/2003 11:13:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00790972
Message ID:
00791143
Vues:
20
You're messing it up with both setting a relation + LinkMaster, ChildOrder etc properties in grid. Do either one.

Do not use expressions like Str(rd_rcn)+Alltrim(rd_dsort) but :

padl(rd_rcn,10)+rd_dsort

* Alltrim in an index key is meaningless.
ChildOrder: rd_grdsort
LinkMaster: dd_ear
RecordSource: dd_earappdwg
RelationalExpr: padl(ar_rcn,10)

Below is a sample :
oForm = Createobject('myForm')
oForm.Show
Read Events

Define Class myForm As Form
  Width = 500
  Height = 300
  Add Object parGrid As Grid With Width = 100, Height=300
  Add Object childGrid As Grid With Left = 120, Height=300

  Procedure Load
    Rand(-1)
    Create Cursor crsParent (pkid i)
    Create Cursor crsChild (parentID i, dummy c(1))
    For ix=1 To 10
      Insert Into crsParent Values (ix)
      For jx=1 To 20
        Insert Into crsChild Values (ix, Chr(Asc('A')+Int(Rand()*26)))
      Endfor
    Endfor
    Select crsChild
    Index On Padl(parentID,10)+dummy Tag mySorter
    Set Order To 0 && To demonstrate childorder does this
    Select crsParent
    Locate
  Endproc

  Procedure Init
    With This.parGrid
      .RecordSource = ''
      .ColumnCount = -1
      .RecordSource = 'crsParent'
    Endwith
    With This.childGrid
      .RecordSource = ''
      .ColumnCount = -1
      .RecordSource = 'crsChild'
      .LinkMaster = 'crsParent'
      .RelationalExpr = 'padl(pkid,10)'
      .ChildOrder = 'mySorter'
    Endwith
  Endproc

  Procedure QueryUnload
    Clear Events
  Endproc

Enddefine
Cetin


>Cetin,
>
>Sorry to say, but your solution did not work; when I changed ChildOrder back to rd_rcn it worked showing child table data in grid (albeit, not correct for Grid displayed rows sort order).
>
>When I used your concatenated - 2 field - string index tax from RecordSource (Child table) nothing displayed in Grid.
>
>Here is implementation of your Solution that did not work.
>
>Tables:
>
>Parent (dd_Ear)
>Field: ar_rcn (Integer)
>Index (tag): ar_rcn (Field ar_rcn)
>
>Child (dd_Earappdwg)
>Fields: rd_rcn (Integer), rd_dsort (Char)
>Index (tags):
>rd_rcn (Field rd_rcn), rd_grdsort (Expr: Str(rd_rcn)+Alltrim(rd_dsort))
>
>DD_ear:
>Form (with Grid) Load() method:
> USE DD_ear order rd_rcn share
> USE DD_earappdwg order rd_rcn share
> SET RELATION TO ar_rcn INTO dd_earappdwg IN dd_ear ADDITIVE
>
>Form Grid Properties:
>ChildOrder: rd_grdsort
>LinkMaster: dd_ear
>RecordSource: dd_earappdwg
>RelationalExpr: str(ar_rcn)
>
>Through Form (.SCX) I have function to add records to child table (dd_earappdwg). That is when child records should freshly
>display in Grid (existing child records are displayed in grid when parent table that links them is pointed to via navigation in Form).
>
>Fred Z
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform