After upgrading project to Syncfusion version 18.2.0.47 I am facing an issue in Grid. It was working fine in version 18.1.
I have a requirement to
save student’s subject wise marks, for this I am using two drop down editor in
grid one for student and second for subject.
When I initialize data source with empty records and then I press “+ Add” button it never shows any drop down editor in grid.
And if grid
data source contain one or more records it shows drop downs editor in edit and add
mode. But when I delete all rows, again it never shows any drop down editor in add
mode.
<SfGrid DataSource="results"
AllowPaging="true" AllowSorting="true" Toolbar="@(new
List<string>() { "Add", "Edit", "Delete",
"Cancel", "Update" })">
<GridEditSettings
AllowAdding="true" AllowEditing="true"
AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn
Field="@nameof(StudentResult.Id)"
IsPrimaryKey="true"></GridColumn>
<GridColumn
Field="@nameof(StudentResult.StudentId)"
DataSource="students" EditType="EditType.DropDownEdit"
ForeignKeyField="Id"
ForeignKeyValue="Name"></GridColumn>
<GridColumn
Field="@nameof(StudentResult.SubjectId)"
DataSource="subjects" EditType="EditType.DropDownEdit"
ForeignKeyField="Id"
ForeignKeyValue="Name"></GridColumn>
<GridColumn
Field="@nameof(StudentResult.MarkObtain)"
Edit="EditType.NumericEdit"
Format="######"></GridColumn>
</GridColumns>
</SfGrid>
@code {
public List<StudentResult>
results { get; set; }
public
List<Student> students { get; set; }
public
List<Subject> subjects { get; set; }
protected
override async Task OnInitializedAsync()
{
await
base.OnInitializedAsync();
students
= new List<Student>
{
new
Student{Id=1, Name="Steve Smith"},
new
Student{Id=2, Name="Tony Robbins"}
};
subjects
= new List<Subject>
{
new
Subject{ Id=1, Name="History"},
new
Subject{Id=2, Name="Computer Science"},
new
Subject{Id=3, Name="Law"}
};
//
New Record
results
= new List<StudentResult>();
//
Edit Record
//results
= new List<StudentResult>() { new StudentResult { Id =
Guid.NewGuid().ToString(), StudentId = 1, MarkObtain = 22, SubjectId = 1 } };
StateHasChanged();
}
}