Error processing OnValueSelect event in MultiSelect Dropdown

I have a multiselect dropdown in a valuetemplate of a querybuilder.When I select a item in the multiselect dropdown it fires the OnValueSelect event which I process by updating the querybuilder's rule model. The my StringListSelect function is called by the event completes Ok with no exception generated but after the function completes the follow exceptions fire:

Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll
Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in System.Linq.Expressions.dll
Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.AspNetCore.Components.dll
Exception thrown: 'System.IndexOutOfRangeException' in Microsoft.AspNetCore.Components.dll

I get the following the console of the browser:

blazor.server.js:19 [2020-12-16T11:04:44.917Z] Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'string' to 'string[]'
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at Syncfusion.Blazor.QueryBuilder.Internal.QueryBuilderRules`1.SetOperator()
   at Syncfusion.Blazor.QueryBuilder.Internal.QueryBuilderRules`1.OnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

        protected void StringListSelect(SelectEventArgs e, RuleModel ruleModel)
        {
            try
            {
                string output = JsonConvert.SerializeObject(e.ItemData);
                var SelectedValue = JsonConvert.DeserializeObject<DashBoardScopeListValue>(output).Value;
                ruleModel.Value = SelectedValue;
            }
            catch (Exception ex)
            {
            }
        }

                                        <QueryBuilderColumn @key=@DashBoardTileScopeFieldObj [email protected] [email protected] [email protected] [email protected]>
                                            <QueryBuilderTemplates>
                                                <ValueTemplate>
                                                    @if (context.Operator == "notin" || context.Operator == "in")
                                                    {
                                                        List<DashBoardScopeListValue> DashBoardScopeListValueObj = this.GetDashBoardScopeListValue(context.Field);
                                                        string Placeholder = "BoE";
                                                        string FilterBarPlaceholder = "blah";
                                                    <SfMultiSelect TValue=@string[] Placeholder=@Placeholder Mode="@VisualMode.CheckBox" ShowSelectAll=@true EnableSelectionOrder=@true ShowDropDownIcon=@true DataSource=@DashBoardScopeListValueObj FilterBarPlaceholder=@FilterBarPlaceholder PopupWidth="Auto">
                                                        <MultiSelectFieldSettings Text="Text" Value="Value"></MultiSelectFieldSettings>
                                                        <MultiSelectEvents TValue="string[]" OnValueSelect=@(e => StringListSelect(e, context))></MultiSelectEvents>
                                                    </SfMultiSelect>
                                                    }
                                                    else
                                                    {
                                                        <SfTextBox ValueChange=@(e => StringTextChange(e, context))  Placeholder='Enter custom Value'></SfTextBox>
                                                    }
                                                </ValueTemplate>
                                            </QueryBuilderTemplates>
                                        </QueryBuilderColumn>


1 Reply 1 reply marked as answer

AS Aravinthan Seetharaman Syncfusion Team December 18, 2020 12:26 PM UTC

Hi Michael Aston, 
  
Thanks for contacting Syncfusion support. 
We have checked your reported issue, and we can able to solve this issue by converting the value to string array that is received on OnValueSelect event handler as like below: 
protected void StringListSelect(SelectEventArgs e, RuleModel ruleModel) 
    { 
        string output = JsonConvert.SerializeObject(e.ItemData); 
        var SelectedValue = JsonConvert.DeserializeObject<ItemFields>(output).Id; 
        string[] value = new string[] { SelectedValue }; 
        ruleModel.Value = value; 
    } 
 

Could you please check the above details, and get back to us, if you need further assistance on this. 
  
Regards, 
Aravinthan S 


Marked as answer
Loader.
Up arrow icon