用于 Blazor 的 DevExpress dxDataGrid - "There was an unhandled exception on the current circuit" 错误
DevExpress dxDataGrid for Blazor - "There was an unhandled exception on the current circuit" error
我正在为 Blazor 使用 dxDataGrid 来构建项目,但是当我尝试添加新行时出现一些错误或编辑当前行。
Error: There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in 'CircuitOptions.DetailedErrors'.
[2019-09-26T11:13:47.533Z] Information: Connection disconnected.
我收到了这个错误:
我第一个想到的 SignalR 是 disconnected.but 我不知道为什么或如何配置?
有人知道吗?可以告诉我吗?
根据 Mikhail 的建议,我得到了错误的一些新细节。第一次尝试时出现第一个错误,第二次尝试时出现第二个错误。
Error: System.NullReferenceException: Object reference not set to an instance of an object.
Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
看来我的 code.but 有问题我仍然对这些错误没有任何想法,所以我将我的代码片段粘贴在下面。
<DxDataGrid Id="aa" Data="@activityDtos" @ref="@grid"
ShowFilterRow="false"
RowRemoving="@((dataItem) => OnRowRemoving(dataItem))"
RowUpdating="@((updatingDataItem, newValues) => OnRowUpdating(updatingDataItem, newValues))"
RowInserting="@((newValues) => OnRowInserting(newValues))">
<DxDataGridCommandColumn Width="150px" Context="编辑"></DxDataGridCommandColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActivityCode)" Caption="Activity Code"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActText1)" Caption="Text1"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActText2)" Caption="Text2"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActivityStatusID)" Caption="Status">
<DisplayTemplate>
@{
var feild = (context as ActivityDto).ActivityStatusID == "A" ? "Active" : "Inactive";
<label><span>@feild</span></label>
}
</DisplayTemplate>
<EditTemplate>
<DxComboBox Data="@(new List<string>() { "Active", "Inactive" })"
SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "Active" : "Inactive" )"
SelectedItemChanged="@(newCellValue => ((CellEditContext)context).OnChanged(newCellValue == "Active"))">
</DxComboBox>
</EditTemplate>
</DxDataGridColumn>
<DxDataGridColumn Caption="Default">
<DisplayTemplate>
@{
var id = Guid.NewGuid().ToString();
var isDefault = (context as ActivityDto).IsDefault;
<input id="@id" type="checkbox" checked="@isDefault" />
}
</DisplayTemplate>
</DxDataGridColumn>
</DxDataGrid>
还有C#的代码
string ActivityCode, Text1Value, Text2Value, Status,Status1;
IQueryable<ActivityDto> activityDtos;
ActivityFormDataItem editFormData = new ActivityFormDataItem()
{
Status = "All",
CompanyId = 37
};
protected override async Task OnInitializedAsync()
{
activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
SearchDtos = await ActivitiesService.SearchDtosForAsync();
}
async void OnRowRemoving(ActivityDto dataItem)
{
ActivitiesService.Remove(dataItem);
await InvokeAsync(StateHasChanged);
}
async void OnRowUpdating(ActivityDto dataItem, Dictionary<string, object> newValue)
{
ActivitiesService.Update(dataItem, newValue);
await InvokeAsync(StateHasChanged);
}
async void OnRowInserting(Dictionary<string, object> newValue)
{
ActivitiesService.Insert(newValue);
await InvokeAsync(StateHasChanged);
}
protected async Task OnAfterRenderAsync()
{
editFormData = new ActivityFormDataItem()
{
Status = Status1,
ActivityCode=ActivityCode,
CompanyId = 37,
Text1Value=Text1Value,
Text2Value=Text2Value
};
activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
if (!string.IsNullOrEmpty(editFormData.Status))
editFormData.Status = editFormData.Status == "A" ? "Active" : "Inactive";
else
editFormData.Status = "All";
await InvokeAsync(StateHasChanged);
}
查阅 There was an unhandled exception on the current circuit article and other recommendations from the official https://github.com/DevExpress/Blazor 存储库:
如果您看到此错误消息或类似消息,请将以下代码添加到 Startup.cs 文件中声明的 ConfigureServices 方法中:
services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });
一旦您能够获得更多详细信息,请将它们全部收集起来并提交 ticket 到 DevExpress 支持中心以获得专门的帮助。
我终于找到了为什么我的代码会出现这样的错误。编辑当前行时类型转换有问题。
<DxComboBox Data="@(new List<string>() { "Active", "Inactive" })"
SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "Active" : "Inactive" )"
SelectedItemChanged="@(newCellValue => ((CellEditContext)context).OnChanged(newCellValue == "Active"))">
</DxComboBox>
其实我的思路不一样,浪费了很多时间
我正在为 Blazor 使用 dxDataGrid 来构建项目,但是当我尝试添加新行时出现一些错误或编辑当前行。
Error: There was an unhandled exception on the current circuit, so this circuit will be terminated. For more details turn on detailed exceptions in 'CircuitOptions.DetailedErrors'.
[2019-09-26T11:13:47.533Z] Information: Connection disconnected.
我收到了这个错误:
我第一个想到的 SignalR 是 disconnected.but 我不知道为什么或如何配置?
有人知道吗?可以告诉我吗?
根据 Mikhail 的建议,我得到了错误的一些新细节。第一次尝试时出现第一个错误,第二次尝试时出现第二个错误。
Error: System.NullReferenceException: Object reference not set to an instance of an object.
Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
看来我的 code.but 有问题我仍然对这些错误没有任何想法,所以我将我的代码片段粘贴在下面。
<DxDataGrid Id="aa" Data="@activityDtos" @ref="@grid"
ShowFilterRow="false"
RowRemoving="@((dataItem) => OnRowRemoving(dataItem))"
RowUpdating="@((updatingDataItem, newValues) => OnRowUpdating(updatingDataItem, newValues))"
RowInserting="@((newValues) => OnRowInserting(newValues))">
<DxDataGridCommandColumn Width="150px" Context="编辑"></DxDataGridCommandColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActivityCode)" Caption="Activity Code"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActText1)" Caption="Text1"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActText2)" Caption="Text2"></DxDataGridColumn>
<DxDataGridColumn Field="@nameof(ActivityDto.ActivityStatusID)" Caption="Status">
<DisplayTemplate>
@{
var feild = (context as ActivityDto).ActivityStatusID == "A" ? "Active" : "Inactive";
<label><span>@feild</span></label>
}
</DisplayTemplate>
<EditTemplate>
<DxComboBox Data="@(new List<string>() { "Active", "Inactive" })"
SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "Active" : "Inactive" )"
SelectedItemChanged="@(newCellValue => ((CellEditContext)context).OnChanged(newCellValue == "Active"))">
</DxComboBox>
</EditTemplate>
</DxDataGridColumn>
<DxDataGridColumn Caption="Default">
<DisplayTemplate>
@{
var id = Guid.NewGuid().ToString();
var isDefault = (context as ActivityDto).IsDefault;
<input id="@id" type="checkbox" checked="@isDefault" />
}
</DisplayTemplate>
</DxDataGridColumn>
</DxDataGrid>
还有C#的代码
string ActivityCode, Text1Value, Text2Value, Status,Status1;
IQueryable<ActivityDto> activityDtos;
ActivityFormDataItem editFormData = new ActivityFormDataItem()
{
Status = "All",
CompanyId = 37
};
protected override async Task OnInitializedAsync()
{
activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
SearchDtos = await ActivitiesService.SearchDtosForAsync();
}
async void OnRowRemoving(ActivityDto dataItem)
{
ActivitiesService.Remove(dataItem);
await InvokeAsync(StateHasChanged);
}
async void OnRowUpdating(ActivityDto dataItem, Dictionary<string, object> newValue)
{
ActivitiesService.Update(dataItem, newValue);
await InvokeAsync(StateHasChanged);
}
async void OnRowInserting(Dictionary<string, object> newValue)
{
ActivitiesService.Insert(newValue);
await InvokeAsync(StateHasChanged);
}
protected async Task OnAfterRenderAsync()
{
editFormData = new ActivityFormDataItem()
{
Status = Status1,
ActivityCode=ActivityCode,
CompanyId = 37,
Text1Value=Text1Value,
Text2Value=Text2Value
};
activityDtos = await ActivitiesService.ActivitiesForAsync(editFormData);
if (!string.IsNullOrEmpty(editFormData.Status))
editFormData.Status = editFormData.Status == "A" ? "Active" : "Inactive";
else
editFormData.Status = "All";
await InvokeAsync(StateHasChanged);
}
查阅 There was an unhandled exception on the current circuit article and other recommendations from the official https://github.com/DevExpress/Blazor 存储库:
如果您看到此错误消息或类似消息,请将以下代码添加到 Startup.cs 文件中声明的 ConfigureServices 方法中:
services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });
一旦您能够获得更多详细信息,请将它们全部收集起来并提交 ticket 到 DevExpress 支持中心以获得专门的帮助。
我终于找到了为什么我的代码会出现这样的错误。编辑当前行时类型转换有问题。
<DxComboBox Data="@(new List<string>() { "Active", "Inactive" })"
SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "Active" : "Inactive" )"
SelectedItemChanged="@(newCellValue => ((CellEditContext)context).OnChanged(newCellValue == "Active"))">
</DxComboBox>
其实我的思路不一样,浪费了很多时间