Entity with list of entities, batch editing not working as intended

Hi, I am using blazor datagrid for my entity ReadingSetModel. ​Each ReadingSetModel contains 

public List<ReadingAnchorValueModel> ReadingAnchorValues { get; set; } = new List<ReadingAnchorValueModel>();

Each  ReadingAnchorValueModel ​contains 

public decimal? RawReading { get; set; }

The Idea is that the user will look at all raw readings that the reading set contains as below 
Image_9668_1748914545315


The display is working correctly, however, I am struggling to implement batch editing. Field in the column does not link properly, so I went with template and edit template, which kind of works but still does not show which ones have been edited properly. 

Further when I try to have single click work 
https://blazor.syncfusion.com/documentation/datagrid/batch-editing#how-to-make-editing-in-single-click-and-arrow-keys

It will not try edit the correct cell.


Please let me know a good way to link the raw reading so that batch editing works.


This is my current grid column, each column is generated within a loop based on a possible anchors

<GridColumn HeaderText="@(anchor.Name)" TextAlign="TextAlign.Center" >

  <Template>

    @{


      ReadingSetModel readingSet = (context as ReadingSetModel);


      <div>

        @(readingSet.ReadingAnchorValues.FirstOrDefault(rav => rav.AnchorId == anchor.Id).RawReading)

      </div>

    }

  </Template>

  <EditTemplate>

    @{


      ReadingSetModel readingSet = (context as ReadingSetModel);


      ReadingAnchorValueModel? readingAnchorValue = readingSet.ReadingAnchorValues.FirstOrDefault(rav => rav.AnchorId == anchor.Id);


      if (readingAnchorValue is not null)

      {

        <InputNumber @bind-Value="readingAnchorValue.RawReading" />

      }

    }

  </EditTemplate>

</GridColumn>


3 Replies

NP Naveen Palanivel Syncfusion Team June 4, 2025 01:35 PM UTC

Hi Braden Kayne,

We have reviewed your query and it appears that your Grid uses a stacked header configuration. You are encountering an issue while performing batch editing. To better understand your requirement and assist you further, please share the following details:


  • Please provide the code for the grid and the model class that is being used.
  • Also, I would appreciate it if you could explain the model class in more detail. Specifically, I would like to know whether it involves a one-to-many relationship.
  • Please share a video demonstrating the issue. It would make it easier to understand and identify the problem visually.
  • If possible, please share a simple sample that reproduces the issue, so we can investigate and assist you more effectively.


These details will help us validate your requirement and provide the best possible solution.

Best regards,
Naveen



BK Braden Kayne June 10, 2025 11:05 PM UTC

Hi Naveen. thanks for getting back to me, I have made a small mock up of the issue.

The idea is that there are sets containing value objects, which have a raw reading which should be able to be edited. Two problems is that the change highlight is not working, as it highlights the cell even if the value has not changed. Further single cell editing chooses the first cell instead of the correct cell.

@using Syncfusion.Blazor.Buttons

@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.Inputs

@using Syncfusion.Blazor.Navigations


<SfGrid DataSource="@Sets" @ref="Grid" AllowPaging="true" GridLines="GridLine.Both" AllowTextWrap="true">

  <GridSelectionSettings Mode="Syncfusion.Blazor.Grids.SelectionMode.Row" Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>

  <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Batch">

  </GridEditSettings>

  <GridSelectionSettings Mode="Syncfusion.Blazor.Grids.SelectionMode.Both"></GridSelectionSettings>

  <GridEvents CellSelected="CellSelectHandler" TValue="Set"></GridEvents>

  <GridTextWrapSettings WrapMode="WrapMode.Header"></GridTextWrapSettings>

  <GridColumns>

    <GridColumn Field=@nameof(Set.Id) IsPrimaryKey="true" Visible="false" TextAlign="TextAlign.Right"></GridColumn>

    <GridColumn Field=@nameof(Set.Date) HeaderText="Date" TextAlign="TextAlign.Center" Width="11%"></GridColumn>

    <GridColumn HeaderText="Raw Readings" TextAlign="TextAlign.Center" Width="12%">

      <GridColumns>

        @for (int i = 0; i < 4; i++)

        {

          int currentIndex = i + 0;

          <GridColumn HeaderText="@(currentIndex.ToString())" TextAlign="TextAlign.Center">

            <Template>

              @{


                Set set = (context as Set);


                <div>

                  @(set.Values.FirstOrDefault(rav => rav.AnchorId == currentIndex).RawReading)

                </div>

              }

            </Template>

            <EditTemplate>

              @{


                Set set = (context as Set);


                Value? value = set.Values.FirstOrDefault(rav => rav.AnchorId == currentIndex);


                if (value is not null)

                {

                  <InputNumber @bind-Value="value.RawReading" />

                }

              }

            </EditTemplate>

          </GridColumn>

        }

      </GridColumns>

    </GridColumn>

  </GridColumns>

</SfGrid>


@code {


  public SfGrid<Set> Grid { get; set; }


  public class Set

  {

    public Guid Id { get; set; } = Guid.NewGuid();

    public DateTime Date { get; set; }

    public List<Value> Values { get; set; } = new();

  }


  public class Value

  {

    public int AnchorId { get; set; }

    public decimal RawReading { get; set; }

  }


  public List<Set> Sets = new();


  protected override void OnInitialized()

  {

    Value value1 = new Value

      {

        AnchorId = 0,

        RawReading = 0

      };

    Value value2 = new Value

      {

        AnchorId = 1,

        RawReading = 1

      };

    Value value3 = new Value

      {

        AnchorId = 2,

        RawReading = 2

      };

    Value value4 = new Value

      {

        AnchorId = 3,

        RawReading = 3

      };


    Set set = new Set

      {

        Date = DateTime.Now

      };


    set.Values.Add(value1);

    set.Values.Add(value2);

    set.Values.Add(value3);

    set.Values.Add(value4);


    Sets.Add(set);


    base.OnInitialized();

  }


  public async Task CellSelectHandler(CellSelectEventArgs<Set> args)

  {

    //get selected cell index

    var CellIndexes = await Grid.GetSelectedRowCellIndexesAsync();

    //get the row and cell index

    var CurrentEditRowIndex = CellIndexes[0].Item1;

    var CurrentEditCellIndex = (int)CellIndexes[0].Item2;

    //get the available fields

    var Fields = await Grid.GetColumnFieldNamesAsync();

    // edit the selected cell using the cell index and column name

    await Grid.EditCellAsync(CurrentEditRowIndex, Fields[CurrentEditCellIndex]);

  }

}



PS Prathap Senthil Syncfusion Team June 11, 2025 12:19 PM UTC

We have checked your code, and you want to bind one to many relationship columns(List<Class> ). Based on your requirement currently we don’t have support for this feature. Already, we have already considered a feature task to implement this feature “Provide data operation for one-to-many relationship columns” request, and added this to our feature request list. Based on specific parameters including product vision and technological feasibility we will implement this feature in any of our upcoming releases.


Please follow up on the below feedback report page link for future updates regarding the release timeline of this feature.


Feedback Link : https://www.syncfusion.com/feedback/12731/provide-data-operation-for-one-to-many-relationship-columns  


You can also communicate with us regarding the open feature any time using our above feedback report page. We do not have immediate plan to implement this feature and it will be included in any of our upcoming releases. So that we will prioritize the improvement for every release based on demands.

You can communicate with us regarding the open features at any time using the above Feature Report page.


Loader.
Up arrow icon