yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
33
Quintiq file version 2.0
#parent: #root
Method PanelSearchProducts () id:Method_ApplicationLibMacroPlanner_PanelSearchProducts
{
  #keys: '[113694.2.1027230159]'
  Body:
  [*
    // Search products by string, highlight & select the instances in the list.
    if( not isnull( MacroPlan ) )
    { 
      ApplicationLibMacroPlanner.SetFilters(); // to retain the checkbox filters 
      filter := GUIDataSetLevelProducts.FixedFilter();
      
      if( EditorSearchProduct.Text() <> '' )
      {
        products := MacroPlan.GetProductsByName( EditorSearchProduct.Text() );
        
        if( products.Size() < 1000 ) // Performance cap
        {
          DataHolderProducts.Data( products.Copy() );
          
          // Using recursive IsParentin filter is very expensive, so we add the parent to the dataholder and do a simpel exists filter
          productswithparents := Product_MP::GetAllParents( products );
          productswithparents := productswithparents.Union( products );           
          DataHolderSearchProduct.Data( productswithparents.Copy() );
              
          filter := filter + ' and exists( dataholdersearchproduct, Elements, e, e = object ) '; // to retain the checkbox filters     
        }      
      }
      GUIDataSetLevelProducts.FixedFilter( filter );
    }
  *]
}