TOPIC: Problem with FindControl?
#1610
Problem with FindControl? 10 Months, 1 Week ago
I'm having a problem I that I'm not having any luck solving. I believe there is a problem with FindControl. Here is my code:

Code:


#(Access
  'flight_plan'
  title: ''
  (Vert
    (Horz fp_name Skip fp_plan_date Skip fp_flown_date)
    Skip
    (Horz (fp_start_point) Skip (ac_tail_no) Skip
      (fp_speed) Skip (fp_fuel))
    Skip
    (Tabs themed: true
      (Vert
        (Browse 'fp_leg sort fpl_position'
          columns: (fpl_name, fpl_distance, fpl_tc, fpl_altitude,
            fpl_extra_fuel_use, fpl_wind_direction, fpl_wind_speed,
            fpl_wind_temperature, fpl_mag_variation, fpl_comment)
          linkField: 'fp_id'
          name: 'fp_leg_id'
        )
        (Horz
          (Button 'Order' name: 'Order Legs')
          (Button 'Up' name: 'Move Leg Up')
          (Button 'Down' name: 'Move Leg Down'))
        Tab: 'Leg Definition'
      )
      (Vert
        (Browse 'fp_aids sort fpa_position'
          columns: (fpa_name, fpa_elevation, fpa_traffic_pattern, fpa_runways,
            fpa_atis, fpa_approach, fpa_ground, fpa_ctaf, fpa_unicom,
            fpa_fss, fpa_comment)
          linkField: 'fp_id'
          name: 'fp_aid_id'
        )
        (Horz
          (Button 'Order' name: 'Order Aids')
          (Button 'Up' name: 'Move Aid Up')
          (Button 'Down' name: 'Move Aid Down'))
        Tab: 'Airports'
      )
      (NoPrompt fp_comment Tab: 'Notes')
      (NoPrompt fp_preview Tab: 'Preview')
      (NoPrompt fp_route_url Tab: 'Sectional')
    )
    Skip
    (Button 'Export')
  )
)

New()
  {
  .aids = .Access.FindControl('fp_aid_id')
  .legs = .Access.FindControl('fp_leg_id')
  Print('.legs=' $ Display(.legs))
  Print('.aids=' $ Display(.aids))
  }



When I run this control, everything works right but in the console, I get:

Code:


.legs=BrowseControl()
.aids=false



Now... if I simply move the (Vert (Browse fp_aids...) code above the fp_legs, then the output flips:

Code:


.legs=false
.aids=BrowseControl()



Can someone help me solve this problem?

Oh, I have two rules (fp_aid_id and fp_leg_id) that simply does:

Code:


function() {
  return .fp_id
}



so that I can have two browse controls keyed off the same value but with different names.

Jeremy
 
 
Last Edit: 2009/10/14 20:33 By jeremy_c. Reason: Added note about fp_aid_id and fp_leg_id rules.
 
#1611
Re:Problem with FindControl? 10 Months, 1 Week ago
Hey Jeremy!

I think the problem is that the second tab is not constructed when you do your .FindControl. I think you would have to do something like:

Code:


New()
    {
    data = .Access.GetRecordControl()
    tabs = data.Vert.Tabs
    tabs.ConstructTab(1)
    .aids = .Access.FindControl('fp_aid_id')
    .legs = .Access.FindControl('fp_leg_id')
    Print('.legs=' $ Display(.legs))
    Print('.aids=' $ Display(.aids))
    }



The other option is to put "constructAll: true" on your TabsControl. We usually do not do this because it can cause some "flashing" but you can always give it a try.

Jennie
 
 
#1612
Re:Problem with FindControl? 10 Months, 1 Week ago
Ah yes! This has bitten me before I can't believe I didn't think of that :-(

Thanks for jogging my memory.