We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to bind Rating value to database

Hello,


I am trying to bind Rating to database using code below


   <GridColumn Field="@nameof(Note.Rating)" HeaderText="Rating" Width="30">

                        <Template Context="GFDS">

                            <SfRating Value="@((GFDS as Note).Rating)"></SfRating>

                        </Template>

                    </GridColumn>


However, It does not work. Below is my class

 public class Note

    {

        public int ID { get; set; }


        public string? Notes { get; set; }


        public string? Category { get; set; }


        public string? DeliverBy { get; set; }


        public string? Links { get; set; }


        public double? Rating { get; set; }


        public string? GitHubLink { get; set; }


        public DateTime? DateInsert { get; set; }


        public DateTime? DateUpdate { get; set; }


    }


Best regards

SAO



5 Replies

NP Naveen Palanivel Syncfusion Team April 15, 2023 05:19 AM UTC

Hi Sao,


We checked your query, we would like to infrom that You can change the values by passing the context in the valuechange event handler of SfRating. In addition, we have support to update the rows using UpdateRowAsync method. By using this way , you can able to bind the Rating value to the database. . Kindly check the below attached code snippet and sample for your reference.



<GridColumn Field=@nameof(EmployeeData.Customerrate) HeaderText="Customerrate ID" TextAlign="TextAlign.Right" Width="120">

            <Template >

                @{

                    var employee = (context as EmployeeData);

                    <SfRating Value="@(employee.Customerrate)" ValueChanged="@((args)=>Changes(args,employee))"></SfRating>

 

                }

            </Template>

        </GridColumn>




    SfGrid<EmployeeData> Grid;

 

    public async Task Changes(double args, EmployeeData val)

    {

       

        var index = await Grid.GetRowIndexByPrimaryKeyAsync(val.EmployeeID);

       

        val.Customerrate = args;

     

        await Grid.UpdateRowAsync(index, val);

      

 

      

    }

 



Link : https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_UpdateRowAsync_System_Int32__0_
          Events in Rating Component | Syncfusion


If you still face difficulties then kindly share the below details to validate the issue further at our end.


  1. Can you please provide the details on how  the data is bind to the  grid
  2. Share us the entire Grid code snippet along with model class.
  3. Share us the video demonstration of the issue
  4. If possible share us an simple issue reproduceable sample.

The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.


Regards,

Naveen Palanivel


Attachment: Blazor_Rating_6409b9dc.zip


SA Sao April 15, 2023 09:03 AM UTC

Hello,

I get an error as follow:

CS1503 Argument 1: cannot convert from 'double?' to 'double'



My code is as follow:


@page "/Grids/Notes"

@using MyApp.Models

@using MyApp.Services

@using Syncfusion.Blazor.Data

@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.Buttons

@using Syncfusion.Blazor.Inputs

@inject IMyDBServices MyDBServices

@inject MyApp.Services.CodeHelper Helper


<h3>Notes</h3>

<div class="col-lg-12 control-section">

    <div class="content-wrapper">

        <div class="row">

            <SfGrid DataSource="@ListGridDataSource" Toolbar="@Helper.Toolbars"

                    ContextMenuItems="@Helper.ContextMenus" AllowFiltering="true"

                    AllowPaging="true" ShowColumnChooser=true AllowSorting=true AllowTextWrap=true AllowExcelExport=true>

                <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>

                <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="Syncfusion.Blazor.Grids.EditMode.Dialog" ShowDeleteConfirmDialog="true">

                    <Template Context="ABC">

                        @{

                            var GFDS = (ABC as Note);

                            <div class="EditTemplate">


                                <div class="row EditRowSpacing">

                                    <div class="mb-12">

                                        <SfTextBox Multiline=false @bind-Value="@((GFDS as Note).Notes)"

                                               Placeholder="Note Description" FloatLabelType="@FloatLabelType.Always">

                                        </SfTextBox>

                                    </div>

                                </div>

                                <div class="row EditRowSpacing">

                                    <div class="col-md-4">

                                        <SfTextBox Multiline=false @bind-Value="@((GFDS as Note).Category)"

                                               Placeholder="Note Category" FloatLabelType="@FloatLabelType.Always">

                                        </SfTextBox>

                                    </div>

                                    <div class="col-md-4">

                                        <SfTextBox Multiline=false @bind-Value="@((GFDS as Note).DeliverBy)"

                                               Placeholder="Delivered By" FloatLabelType="@FloatLabelType.Always">

                                        </SfTextBox>

                                    </div>

                                    <div class="col-md-4">

                                        <label for="GFDS.IsQA">Is Q&A?</label><br />

                                        <SfCheckBox @bind-Checked="GFDS.IsQA"></SfCheckBox>

                                    </div>

                                </div>

                                <div class="row EditRowSpacing">

                                    <div class="mb-8">

                                        <SfTextBox Multiline=true @bind-Value="@((GFDS as Note).Links)"

                                               HtmlAttributes="@Helper.htmlAttribute2Row"

                                               Placeholder="Link address" FloatLabelType="@FloatLabelType.Always">

                                        </SfTextBox>

                                    </div>


                                </div>

                                <div class="row EditRowSpacing">


                                    <div class="mb-12">

                                        <SfTextBox Multiline=true @bind-Value="@((GFDS as Note).GitHubLink)"

                                               HtmlAttributes="@Helper.htmlAttribute8Row"

                                               Placeholder="Enter Source Code address" FloatLabelType="@FloatLabelType.Always">

                                        </SfTextBox>

                                    </div>

                                </div>

                            </div>

                        }

                    </Template>

                </GridEditSettings>

                <GridEvents OnActionBegin="ActionBeginHandler" TValue="Note"></GridEvents>

                <GridPageSettings PageSize="10"></GridPageSettings>

                <GridColumns>

                    <GridColumn Field="@nameof(Note.ID)" IsIdentity=true IsPrimaryKey=true Width="8">

                        <EditTemplate></EditTemplate>

                    </GridColumn>

                    <GridColumn Field="@nameof(Note.Notes)" Width="50" MaxWidth="50" TextAlign="TextAlign.Left"></GridColumn>

                    <GridColumn Field="@nameof(Note.Category)" Width="30"></GridColumn>

                    <GridColumn Field="@nameof(Note.DeliverBy)" HeaderText="Delivered By" Width="30"></GridColumn>

                    <GridColumn Field="@nameof(Note.Links)" Width="30"></GridColumn>

                    <GridColumn Field=@nameof(Note.Rating) HeaderText="Rating ID" TextAlign="TextAlign.Right" Width="120">

                        <Template>

                            @{

                                var rate = (context as Note);

                                <SfRating Value="@(rate.Rating)" ValueChanged="@((args)=>Changes(args,rate))"></SfRating>


                            }

                        </Template>

                    </GridColumn>

                    <GridColumn Field="@nameof(Note.IsQA)" HeaderText="Q&A?" DefaultValue="0" TextAlign="TextAlign.Center" DisplayAsCheckBox=true Width="10"></GridColumn>

                    <GridColumn Field="@nameof(Note.GitHubLink)" Width="30" Visible=false ShowInColumnChooser=true>

                        <EditTemplate Context="GFDS">

                            <div>

                                <SfTextBox Multiline=true @bind-Value="@((GFDS as Note).GitHubLink)" HtmlAttributes="@Helper.htmlAttribute6Row" Placeholder="Enter Source Code address" FloatLabelType="@FloatLabelType.Auto"></SfTextBox>

                            </div>

                        </EditTemplate>

                    </GridColumn>

                </GridColumns>

            </SfGrid>

        </div>

    </div>

</div>

@code {


    private SfGrid<Note> DefaultGrid;

    public IEnumerable<Note> ListGridDataSource { get; set; }


    protected override void OnInitialized()

    {

        ListGridDataSource = MyDBServices.GetNote();


    }

    public void ActionBeginHandler(ActionEventArgs<Note> Args)

    {

        if (Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))

        {

            if (Args.Action == "Add")

            {

                Args.Data.DateInsert = DateTime.Now;

                MyDBServices.InsertNote(Args.Data);

            }

            else

            {

                Args.Data.DateUpdate = DateTime.Now;

                MyDBServices.UpdateNote(Args.Data.ID, Args.Data);

            }

        }

        if (Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Delete))

        {

            MyDBServices.DeleteNote(Args.Data.ID);

        }

    }

    public async Task Changes(double args, Note val)

    {


        var index = await DefaultGrid.GetRowIndexByPrimaryKeyAsync(val.ID);


        val.Rating = args;


        await DefaultGrid.UpdateRowAsync(index, val);




    }

}



Regards


Sao



KB Kin Bueno April 15, 2023 10:22 AM UTC

No not all grid columns are pre-defined as sustainable to Aus logics not even defined as constriction to overhead systems such as odell, and camtrue.

Amazon web services, API, or CTSI, or CTSSI, are not bound by command logic as even as its procurement plan so as to its fibre optics, as statistics generated in INVSCI.


https://cryphosnegative.blogspot.com/



NP Naveen Palanivel Syncfusion Team April 26, 2023 09:25 AM UTC

Hi Sao,


We have confirmed this as an breaking issue and logged the defect report  “Nullable double value is not working in Rating "  for the same. Thank you for taking time to report this issue and helping us to improve our product. At Syncfusion, we are committed to fix all validated defects (subject to technological feasibility and Product Development Life Cycle) and this fix will be included in our upcoming patch release which is expected to be rolled out on or  1st weekly patch release after our Vol 1 SP release 2023.  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/42968/nullable-double-value-is-not-working-in-rating


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”



Regards,

Naveen Palanivel



NP Naveen Palanivel Syncfusion Team May 17, 2023 02:18 PM UTC

Hi Sao,


We are glad to announce that, we have included the fix for the issue “Nullable double value is not working in Rating” in our 21.2.5 release.  So please upgrade to our latest version of the Syncfusion package to resolve the reported issue.


NuGet : https://www.nuget.org/packages/Syncfusion.Blazor.Grid


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,

Naveen.


Loader.
Live Chat Icon For mobile
Up arrow icon