This is a migrated thread and some comments may be shown as answers.

Editable grid fails with Synchronous operations are disallowed

1 Answer 415 Views
Grid
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 16 Dec 2019, 09:40 AM

Hi,

 

I am trying to create a grid like this

.Read(read => read.Action(nameof(RcaDatastructureController.Editing_ReadRcas), "RcaDatastructure", new { key = Model.Product.ProductKey })))*@
    @(Html.Kendo().Grid<DashboardRcaRecord>()
        .Name("grid")
                .ToolBar(toolbar =>
                     {
                         toolbar.Create();
                         toolbar.Search();
                     })
                .Columns(columns =>
                {
 
                    columns.Bound(p => p.JiraLink).Title("RCA link")
                        .ClientTemplate($"<a href=\"#: data.JiraLink#\" target=\"_blank\">#: data.Summary #</a>")
                        .Width(100);
                    columns.Bound(p => p.PCA).Width(200);
                    columns.Bound(p => p.QbStatus).Width(100);
                    columns.Bound(p => p.DataStructureLink).Width(100);
                    columns.Bound(p => p.FixStatus).Width(100);
                    columns.Bound(p => p.NumberOfCRsToResolve).Title("No of Change Requests")
                        .ClientHeaderTemplate("No of<br/>Customer<br/>Defects").Width(50);
                    columns.Bound(p => p.NumberOfE2EsToResolve).Title("No of End-to-ends")
                        .ClientHeaderTemplate("No of<br/>End-to-ends").Width(50);
                    columns.Bound(p => p.NumberOfMTsToResolve).Title("No of Monitor Tasks")
                        .ClientHeaderTemplate("No of<br/>Monitor<br/>Tasks").Width(50);
                    columns.Bound(p => p.NumberOfSaasIncsToResolve).Title("No of Saas Incidents")
                        .ClientHeaderTemplate("No of<br/>Saas<br/>Incidents").Width(50);
                    columns.Bound(p => p.NumberOfDefectsToResolve).Title("No of Defects")
                        .ClientHeaderTemplate("No of<br/>Defects").Width(50);
                    columns.Bound(p => p.NumberOfCustomerDefectsToResolve).Title("No of Customer Defects")
                        .ClientHeaderTemplate("No of<br/>Customer<br/>Defects").Width(50);
                    columns.Bound(p => p.NumberOfSpecsToResolve).Title("No of Specs").ClientHeaderTemplate("No of<br/>Specs").Width(50);
                    columns.Command(command => { command.Custom("Edit").Click("editRca"); }).Width(70);
                })
                .Editable(e=>e.Mode(GridEditMode.InLine))
        .Sortable(sortable => { sortable.SortMode(GridSortMode.MultipleColumn); })
        .Filterable()
        .Pageable(pgbl => pgbl.Refresh(true).PageSizes(true))
        .DataSource(dataSource => dataSource.Ajax()
        .Model(model =>
        {
            model.Id(p => p.JiraKey);
        })
        .Read(read => read.Action(nameof(RcaDatastructureController.Editing_ReadRcas), "RcaDatastructure", new { key = Model.Product.ProductKey })))
    )
<script type="text/javascript">
    function editRca(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
 
        window.location.href = "@Url.Action(nameof(RcaDatastructureController.RcaDetails), "RcaDatastructure", new { key=Model.Product.ProductKey})&rcaKey="+dataItem.JiraKey;
    }
    $(function () {
        var addButton = $('a.k-button.k-button-icontext.k-grid-add');
        addButton.unbind('click');
        addButton.click(function () {
            window.location.href = "@Url.Action(nameof(RcaDatastructureController.RcaDetails), "RcaDatastructure", new { key=Model.Product.ProductKey})";
        });
    });
</script>

But it fails at runtime with the exception

nvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
Microsoft.AspNetCore.Server.IIS.Core.HttpResponseStream.Write(byte[] buffer, int offset, int count)
Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Write(byte[] buffer, int offset, int count)
Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter.FlushInternal(bool flushEncoder)
Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter.Dispose(bool disposing)
System.IO.TextWriter.Dispose()
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|21_0(ResourceInvoker invoker, IActionResult result)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

 

However if I comment lines

toolbar.Create();

and

.Editable(e=>e.Mode(GridEditMode.InLine))

makeing grid readonly everything seems to work fine. Any idea why this is happening ?

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 19 Dec 2019, 08:34 AM

Hi Raghu,

I have investigated the declaration of the Kendo UI Grid and it appears that everything has been set accordingly. Is it possible for you to share more details on the editors that are utilized for the grid? For instance, in case there are editors that have the .Name() option configured, I encourage you to alternate the syntax from ComboBox to ComboBoxFor(x=>x) option.

A general way to resolve this issue has been discussed in the StackOverflow article below:

https://stackoverflow.com/questions/47735133/asp-net-core-synchronous-operations-are-disallowed-call-writeasync-or-set-all

Let me know in case the issue persists.

 

Regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or