Backwards compatibility of search mode

The Smart Client 2020 R1 release appears to have a minor backwards compatibility break in the search feature. 2020 R1 introduced a DisplayMode option to the FilterConfigurationBase class, which defaults to a drop down popup element - this is different to the behaviour in 2019 R3 where the element was displayed inline.

The problem is that updating the MIP SDK to 2020 R1 and explicitly setting the display mode to SnapToParentWidth causes a hard crash when the plugin is loaded into Smart Client 2019 R3.

Is there any way to ensure consistent behavior across both 2019 R3 and 2020 R1 without using two separate plugin builds? A runtime version check to only set the display mode when in the 2020 R1 Smart Client still causes the crash.

Hi Morgan

Unfortunate we had to make this change of the DisplayMode default value. And formal answer to your question would be “no” - you would need to make new build. BUT, of course, there is a workaround: using reflection you can set property to desired value:

        /// <summary>
        /// Set DisplayMode using reflection to make it backwards compatible 
        /// </summary>
        /// <param name="cfg">Object instance to update</param>
        /// <param name="val">Value to set.</param>
        private void SetDisplayModeSafe(FilterConfigurationBase cfg, int val)
        {
            var pi = cfg.GetType().GetProperty("DisplayMode");
            pi?.SetValue(cfg, val);
        }
 
 
// usage example:
var cfg = new SomeFilterConfiguration();
SetDisplayModeSafe(cfg, 2 /*EditControlDisplayMode.SnapToParentWidth*/);               

Thanks Alexey, the workaround is our best option for the moment and it works fine.