Hello,
I have the following Grid:
@(Html.Kendo().Grid<dynamic>()
.Name(
"gridEQ"
)
.Columns(columns =>
{
columns.AutoGenerate(
true
);
})
.Pageable()
.Sortable()
.Scrollable()
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
.NoRecords()
.Filterable(f => f.Enabled(
false
))
.AutoBind(
false
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Read(read => read.Action(
"ReadAsync"
,
"Home"
))
)
)
If I use the Read Action (synchron) like this and an error on the Server exists the error Event of the grid datasource is raised:
public
IActionResult Read(
bool
execute,
string
queryJson,
string
optionsJson, [DataSourceRequest] DataSourceRequest request)
{
try
{
var query = eqService.GetQueryByJsonDict(queryJson.ToJsonDict());
var sql = eqService.BuildQuery(query, optionsJson.ToJsonDict());
if
(execute)
{
SqlConnection c =
new
SqlConnection(
this
.cache.Get(
"ExecuteConnectString"
).ToString());
result = c.Query<dynamic>(sql, commandType: System.Data.CommandType.Text);
return
Json(result.ToDataSourceResult(request));
}
catch
(Exception ex)
{
return
Json(ex);
}
}
If I use the AsyncRead Action like this and an error on the Server exists the error Event of the grid datasource is not fired:
public
async System.Threading.Tasks.Task<ActionResult> ReadAsync(
bool
execute,
string
queryJson,
string
optionsJson, [DataSourceRequest] DataSourceRequest request, CancellationToken cancellationToken)
{
try
{
var query = eqService.GetQueryByJsonDict(queryJson.ToJsonDict());
var sql = eqService.BuildQuery(query, optionsJson.ToJsonDict());
if
(execute)
{
SqlConnection c =
new
SqlConnection(
this
.cache.Get(
"ExecuteConnectString"
).ToString());
result = await c.QueryAsync<dynamic>(sql, commandType: System.Data.CommandType.Text, cancellationToken: cancellationToken);
return
Json(result.ToDataSourceResultAsync(request));
}
catch
(Exception ex)
{
return
Json(ex);
}
}
Why this?
What I'm missing?
robert