Boolean field behavior is wrong in ListBox - Branched from 163328

Hello,

I have the same problem with the boolean field behavior. It's always true.

However, I'm wondering if this issue is related to the checkbox component. When using a SfListBox as follows:

<SfListBox Value="@TaxValues" DataSource="@ItemTaxList" TItem="ItemParamList" TValue="short[]">
<ListBoxSelectionSettings ShowCheckbox="true"></ListBoxSelectionSettings>
<ListBoxFieldSettings Text="Text" Value="Value"></ListBoxFieldSettings>
<ListBoxEvents TItem="ItemParamList" TValue="short[]" ValueChange="TaxListChange"></ListBoxEvents>
</SfListBox>


The ValueChange function always receives all of the items in the list (not only the selected ones)

private void TaxListChange(ListBoxChangeEventArgs<short[],ItemParamList> args)
{
selectedTaxValues = args.Items.ToList();
foreach (var a in args.Items)
{
_logger.LogInformation($"{a.Value}");
}
TotalTaxValues = selectedTaxValues.Sum(c => c.Value);
}


Could you please advise if it's the same issue with the checkbox component?

P.S. I'm using Syncfusion.Blazor 20.1.0.55

Thanks



6 Replies

YA YuvanShankar Arunagiri Syncfusion Team May 25, 2022 12:41 PM UTC

Hi Erick,


We have validated your reported query, for your clarification in ValueChange event args contains the list of item in args.Items and selected item value in args.value. Please refer the below code snippet.

[Index.razor]:

private void ListChange(ListBoxChangeEventArgs<string[], VehicleData> args)

    {

        var selected_item = args.Value;

        var list_of_items = args.Items;

    }


Could you please check the above link and get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A



ER Erick May 26, 2022 12:58 AM UTC

Hi,

Thanks for your response. I have checked and args.Value is always null. It seems that does not work when th SfListBox has TValue="short[]" and it works when TValue="string[]".  In previous versions it used to work with short[].


I made a code sample to show this difference:


@page "/test"

<h1>ListBox Test (String[] Values)</h1>

<SfListBox Value="@StrTaxValues" DataSource="@StrItemTaxList" TItem="StrItemParamList" TValue="string[]">
<ListBoxFieldSettings Text="Text" Value="Value"></ListBoxFieldSettings>
<ListBoxSelectionSettings ShowCheckbox="true"></ListBoxSelectionSettings>
<ListBoxEvents TItem="StrItemParamList" TValue="string[]" ValueChange="StrListChange"></ListBoxEvents>
</SfListBox>

<h1>ListBox Test (Short[] Values)</h1>

<SfListBox Value="@ShortTaxValues" DataSource="@ShortItemTaxList" TItem="ShortItemParamList" TValue="short[]">
<ListBoxFieldSettings Text="Text" Value="Value"></ListBoxFieldSettings>
<ListBoxSelectionSettings ShowCheckbox="true"></ListBoxSelectionSettings>
<ListBoxEvents TItem="ShortItemParamList" TValue="short[]" ValueChange="ShortListChange"></ListBoxEvents>
</SfListBox>

@code {
@* List with string[] values *@
public string[] StrTaxValues { get; set; }

public class StrItemParamList
{
public string Value { get; set; }
public string Text { get; set; }
public string ShortText { get; set; }
}

List<StrItemParamList> StrItemTaxList = new List<StrItemParamList> {
new StrItemParamList() { Value = "128", Text = "Tax A", ShortText = "A" },
new StrItemParamList() { Value = "64", Text = "Tax B", ShortText = "B" },
new StrItemParamList() { Value = "32", Text = "Tax C", ShortText = "C" },
new StrItemParamList() { Value = "16", Text = "Tax D", ShortText = "D" },
};

private void StrListChange(ListBoxChangeEventArgs<string[],StrItemParamList> args)
{
StrTaxValues = args.Value;
if (args.Value != null)
{
foreach (var item in args.Value)
_logger.LogInformation(item);
}
}


@* List with short[] values *@
public short[] ShortTaxValues { get; set; }

public class ShortItemParamList
{
public short Value { get; set; }
public string Text { get; set; }
public string ShortText { get; set; }
}

List<ShortItemParamList> ShortItemTaxList = new List<ShortItemParamList> {
new ShortItemParamList() { Value = 128, Text = "Tax A", ShortText = "A" },
new ShortItemParamList() { Value = 64, Text = "Tax B", ShortText = "B" },
new ShortItemParamList() { Value = 32, Text = "Tax C", ShortText = "C" },
new ShortItemParamList() { Value = 16, Text = "Tax D", ShortText = "D" },
};

private void ShortListChange(ListBoxChangeEventArgs<short[],ShortItemParamList> args)
{
ShortTaxValues = args.Value;
if (args.Value != null)
{
foreach (var item in args.Value)
_logger.LogInformation($"{item}");
}
}

}



YA YuvanShankar Arunagiri Syncfusion Team May 30, 2022 04:19 AM UTC

Hi Erick,


Currently, we don’t have support for your query, so we have logged this improvement as a feature. It will be available in our upcoming patch releases, which is schedule on 18th June, 2022You can track the status of this improvement
using below link from our feedback portal

Feedback link: https://www.syncfusion.com/feedback/35264/provides-the-short-type-values-support-to-tvalue-of-the-listbox


We appreciate your patience until then.


Regards,

YuvanShankar A



ER Erick May 30, 2022 07:03 PM UTC

Thank you very much for your response.  I will modify the code to use string type values in the listbox.


Regards,


Erick



YA YuvanShankar Arunagiri Syncfusion Team May 31, 2022 04:48 AM UTC

Hi Erick,


As promised, we will include this fix in our upcoming patch release which is scheduled on June 18th, 2022. You can track its status from the below feedback link. 


Feedback Link: https://www.syncfusion.com/feedback/35264/provides-the-short-type-values-support-to-tvalue-of-the-listbox



Regards,

YuvanShankar A



YA YuvanShankar Arunagiri Syncfusion Team July 5, 2022 09:15 AM UTC

Hi Erick,


Sorry for the delay.


We are glad to announce that our Essential Studio 2022 Volume 2 release v20.2.0.36 is rolled out. We have included the fix for this issue in this release and is available for download under the following link.


https://www.syncfusion.com/forums/175975/essential-studio-2022-volume-2-main-release-v20-2-0-36-is-available-for-download


Feedback Link: https://www.syncfusion.com/feedback/35264/provides-the-short-type-values-support-to-tvalue-of-the-listbox

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

YuvanShankar A


Attachment: LBShort_54bc2729.zip

Loader.
Up arrow icon