Grid - OdataV4Adaptor patch ignores boolean false value

Hi,
Syncfusion.Blazor 18.4.0.47
.NET Core 3.1.4

From what i read in the changelog this issue should be resolved in 18.4.0.42:
  • #307970#309376#312888 - ODataV4 Patch request ignores boolean value false is fixed.

However when upgrading to the latest release from 18.3.0.48 and clearing nugets, clearing solution etc. we still have this issue. It works false => true but not the other way around.

    public class Arende
    {
        public int Id { get; set; }
        public int KlientId { get; set; }
        public string Beskrivning { get; set; }
        public bool Stängd { get; set; }
    }

    public class ArendeEntity : EntityBase<int>
    {
        public virtual int KlientId { get; set; }
        public virtual string Beskrivning { get; set; }
        public virtual bool Stängd { get; set; }
    }

        [HttpPatch("odata")]
        [ODataRoute("({id})")]
        [EnableQuery]
        public IActionResult Patch([FromODataUri] int id, [FromBody] Delta<Arende> delta)
        {
            using (var unitOfWork = _unitOfWorkFactory.CreateDefault().WithRepository(_arendeRepository))
            using (var transaction = unitOfWork.BeginTransaction(IsolationLevel.Serializable))
            {
                var entity = _arendeRepository.Get(id);
                if (entity == null)
                    return NotFound();

                var arende = entity.ToInternModel();
                delta.Patch(arende); <----- delta does not contain changes for boolean value "Stängd" when changed from true to false in grid and saved.

                entity.KlientId = arende.KlientId;
                entity.Beskrivning = arende.Beskrivning;
                entity.Stängd = arende.Stängd;

                transaction.Commit();

                _logger.LogInformation($"Uppdaterade (PATCH) {entity.Id}");

                return Ok(entity.ToInternModel());
            }
        }

                    <SfDataManager Url="@ViewModel.ODataAddress"
                                   Adaptor="Adaptors.ODataV4Adaptor"
                                   Headers="@ODataHttpHeaders">
                    </SfDataManager>

Same results with either of these:

                    <GridColumn Field=@nameof(Arende.Stängd) HeaderText="Stängd" Width="10%">
                        <EditTemplate>
                            <SfCheckbox @bind-Value="@((context as Arende).Stängd)"></SfCheckbox>
                        </EditTemplate>
                    </GridColumn>

                    <GridColumn Field=@nameof(Arende.Stängd) HeaderText="Stängd" Width="10%" Type="ColumnType.Boolean" >
                        <EditTemplate>
                            <SfCheckbox @bind-Value="@((context as Arende).Stängd)"></SfCheckbox>
                        </EditTemplate>
                    </GridColumn>

                    <GridColumn Field=@nameof(Arende.Stängd) HeaderText="Stängd"  Type="ColumnType.Boolean" EditType="EditType.BooleanEdit" Width="10%"                                                    DisplayAsCheckBox="true">
                    </GridColumn>


Do we need to do something different to get the fix to work or are we doing something wrong? All other fields are updated correctly.






21 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team March 10, 2021 06:36 AM UTC

Hi Jesper,  
 
Thanks for contacting Syncfusion support.  
 
Query: “Do we need to do something different to get the fix to work or are we doing something wrong? All other fields are updated correctly. 
 
Yes, Kindly specify the DefaultValue Attribute as null for that bool property (Stängd) to resolve the reported issue. Refer the below code example.  
 
public class Order 
    { 
        [Key] 
        public int Id { getset; } 
        public string Name { getset; } 
        public DateTime? RegistrationDate { getset; } 
        public int CreditLimit { getset; } 
        [DefaultValue(null)] 
        public bool Active { getset; } 
    } 
  
Please get back o us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer

JE Jesper March 11, 2021 07:24 AM UTC

Hi,

This fixed our issue, thank you.




VN Vignesh Natarajan Syncfusion Team March 12, 2021 04:16 AM UTC

Hi Jesper,  

Thanks for the update.  

We are glad to hear that you have resolved your query using our solution  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 



MC Mason Channer November 2, 2021 03:30 AM UTC

How would you solve the limitation that patch ignores empty string. For example if I have a string value "test" and the clear the cell to "". The empty string does not get serialized, so it does not get patched.


Is there any fix to this limitation or do I have to use the Http Put method?



VN Vignesh Natarajan Syncfusion Team November 2, 2021 05:41 AM UTC

Hi Mason,  
 
Greetings from Syncfusion support  
 
Query: “Is there any fix to this limitation or do I have to use the Http Put method? 
 
No, we do not have any fix to overcome this limitation during the serialization of PATCH request. So we request you to resolve the reported issue by changing the RequestType to PUT from PATCH request. Refer the below code example.  
 
<SfGrid TValue="Order" @ref="GridInstance" AllowPaging="true" Toolbar=@ToolbarItems AllowFiltering="true"> 
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel" /> 
    <GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true"></GridEditSettings> 
    <SfDataManager @ref="DM" Url=http://localhost:64956/odata/books Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> 
. . . ..   
</SfGrid> 
  
@code{ 
    SfGrid<Order> GridInstance; 
    SfDataManager DM { getset; } 
    public string[] ToolbarItems = new string[] { "Add""Edit""Delete""Update""Cancel" }; 
    protected override void OnAfterRender(bool firstRender) 
    { 
        base.OnAfterRender(firstRender); 
        if (DM != null) 
        { 
            RemoteOptions Rm = (DM.DataAdaptor as ODataV4Adaptor).Options; 
            Rm.UpdateType = HttpMethod.Put; 
            (DM.DataAdaptor as ODataV4Adaptor).Options = Rm; 
        } 
    } 
 
 
Please get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan  



MC Mason Channer replied to Vignesh Natarajan December 14, 2021 05:31 PM UTC

Hi Vignesh, when I do this implementation it works great.

However, now when I click save the EditDialog closes when the server returns 500. Before when the server returned 500 when they did not input all the information required the dialog would stay open.


How can I get this original functionality back?



VN Vignesh Natarajan Syncfusion Team December 15, 2021 04:29 AM UTC

Hi Mason,  
 
Thanks for the update.  
 
Query: “now when I click save the EditDialog closes when the server returns 500. Before when the server returned 500 when they did not input all the information required the dialog would stay open. 
 
We have analyzed the reported issue and we understand that you are facing issue with Grid edit dialog that it closes without showing a validation message when validation fails. We suspect that you are using Syncfusion.Blazor Nuget package version below 19.3.0.55 or below. Since it is a known issue, we have fixed the reported issue and included the fix in our 19.3.0.56 version patch release.  
 
Please find the release notes for the same from below  
 
 
So kindly upgrade to our latest version or minimum of 19.3.0.56 version of Syncfusion Nuget package to resolve the reported issue. Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 



MC Mason Channer replied to Vignesh Natarajan December 15, 2021 05:01 PM UTC

Works perfect thanks!



VN Vignesh Natarajan Syncfusion Team December 16, 2021 04:47 AM UTC

Hi Mason,  

Thanks for the acknowledgement.  

We are glad to hear that your query has been resolved.  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 



JO Josh April 18, 2022 03:48 AM UTC

I am on 20.1.0.47 (VS2022/.NET6) and am experiencing the "ignores false" issue regardless of what I set my [DefaultValueAttribute] to. It will not send boolean false to the server. If the boolean is the only thing that has changed, it will send just the Id value in the body of the patch (literaly nothing else, just the Id).



RN Rahul Narayanasamy Syncfusion Team April 19, 2022 03:36 PM UTC

Hi Josh,


Greetings from Syncfusion.


We are currently checking the reported query from our end and we will update the further details within two business days. Until then we appreciate your patience.


Regards,

Rahul



RN Rahul Narayanasamy Syncfusion Team April 21, 2022 02:10 PM UTC

Hi Josh,


Thanks for your patience.


We have considered your query as a bug and logged the defect report “The boolean column value is not updated properly while changing the to false in ODataV4Adaptor” for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and will include the fix in our upcoming patch release which is expected to be rolled out on or before the first week of May 2022. Until then we appreciate your patience.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 


https://www.syncfusion.com/feedback/34335/the-boolean-column-value-is-not-updated-properly-while-changing-the-to-false-in


Regards

Rahul



CA Carl April 21, 2022 06:44 PM UTC

I am also experiencing this issue reported by Josh on 4/17/2022.  I understand that you expect a fix the first week of May.



RN Rahul Narayanasamy Syncfusion Team April 22, 2022 10:19 AM UTC

Hi Carl,


Greetings from Syncfusion.


Yes, we have considered the reported problem “The boolean column value is not updated properly while changing the to false in ODataV4Adaptor” as a bug. The fix for the issue is included in our upcoming patch release which is expected to be rolled out on or before the first week of May 2022. Until then we appreciate your patience.


Regards,

Rahul



NP Naveen Palanivel Syncfusion Team May 18, 2022 01:21 PM UTC

Hi Carl,


Sorry for the inconvenience caused.

Due to some unforeseen circumstances, we could not able to include the fix for the issue “The boolean column value is not updated properly while changing the to false in ODataV4Adaptor" in our weekly patch release as promised. We will include this fix in our upcoming release, which is expected to be rolled out on or before 31th May 2022.

Until then we appreciate your patience.


Regards,

Naveen Palanivel.



ER Erick May 23, 2022 02:29 AM UTC

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






NP Naveen Palanivel Syncfusion Team May 24, 2022 09:08 AM UTC

Hi Erick,

Thanks for the update.



We have branched a separate Forum for the last query. Kindly follow up with the mentioned thread for the further follow ups.


https://www.syncfusion.com/forums/175218/boolean-field-behavior-is-wrong-in-listbox-branched-from-163328



Regards,

Naveen Palanivel.



ER Erick May 26, 2022 11:27 PM UTC

Hello,

Regarding the issue The boolean column value is not updated properly while changing the to false in ODataV4Adaptor", I found that declaring the column value as "bool?" (nullable), the OData adaptor sends the false value.


Regards,

Erick



NP Naveen Palanivel Syncfusion Team May 30, 2022 03:01 PM UTC

Hi Erick,


Thanks for the suggestion.


The Boolean column value is updated when column type is defined as nullable bool. Still we have to fix the issue for the Boolean Type column. so we will update the after the fix issue.


Please get back to us if you have further queries.  


Regards,

Naveen Palanivel.



NP Naveen Palanivel Syncfusion Team June 2, 2022 03:48 PM UTC

Hi Erick,


Sorry for the Inconvenience.


we are not able to include the reported problem “The boolean column value is not updated properly while changing the to false in ODataV4Adaptor"” in our mentioned patch release as promised. We have planned to include this in our upcoming patch release which is expected to be rolled out by 14th June 2022. 

Till then we appreciate your patience.    


Regards, 

Naveen Palanivel



NP Naveen Palanivel Syncfusion Team June 16, 2022 04:40 PM UTC

Hi Erick,  


Sorry for the Inconvenience,

we are not able to include the reported problem “The boolean column value is not updated properly while changing the to false in ODataV4Adaptor"” in our mentioned patch release as promised. We will fix the issue until please we suggest to use that declaring the column value as "bool?" (nullable), the OData adaptor sends the false value.


http://www.syncfusion.com/forums/163328/grid-odatav4adaptor-patch-ignores-boolean-false-value?reply=SgRQZy


Regards,

Naveen Palanivel


Loader.
Up arrow icon