haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Quintiq file version 2.0
#parent: #root
Method PanelSearchSalesSegments () id:Method_ApplicationLibMacroPlanner_PanelSearchSalesSegments
{
  #keys: '[113694.2.1027606231]'
  Body:
  [*
    // Search sales segments by string, highlight & select the instances in the list.
    if( not isnull( MacroPlan ) )
    {
      filter := 'true';
      
      if( EditorSearchSalesSegments.Text() <> '' )
      {
        salessegments := MacroPlan.GetSalesSegmentsByName( EditorSearchSalesSegments.Text() );
        
        if( salessegments.Size() < 1000 ) // Performance cap
        {
          DataHolderSalesSegments.Data( salessegments.Copy() );
          
          // Using recursive IsParentin filter is very expensive, so we add the parent to the dataholder and do a simpel exists filter
          sswithparents := SalesSegment_MP::GetAllParents( salessegments );
          sswithparents := sswithparents.Union( salessegments );
          DataHolderSearchSalesSegment.Data( sswithparents.Copy() );
        
          filter := 'exists( dataholdersearchsalessegment, Elements, e, e = object )';
        }      
      }
      GUIDataSetLevelSalesSegment.FixedFilter( filter ); 
    }
  *]
}