Grid does'nt reload when i have 9 thousand line after ajax call

3 Answers 80 Views
Grid
wajdi
Top achievements
Rank 1
Iron
wajdi asked on 07 May 2021, 03:53 PM | edited on 07 May 2021, 04:41 PM

Hello, 

 

my grid reload data after applying a custom filter so when i have 2000 lines to retrieved, the grid show it correctly but when i passed 9000 line in the result i have 500 error and the grid doesn't refresh. this my ajax call:

thanks for your helping.

Best regards.

 

 


 @(Html.Kendo().Grid<DigitConvForm.Web.Models.DossierViewModel>()
            .Name("Dossiers")
            .Columns(columns =>
            {
                columns.Bound(c => c.Id_Inscription     );
                columns.Bound("Nom").ClientTemplate("#=Civilite# #=Nom# #=Prenom#");
                columns.Bound(c => c.Libelle            );
                columns.Bound(c => c.DateDebut          ).Format("{0:dd/MM/yyyy}");
                columns.Bound(c => c.DateFin            ).Format("{0:dd/MM/yyyy}");
                columns.Bound(c => c.CDV  ).ClientTemplate("<span id = 'badge_#=CDV#' class='badgeTemplate'></span>").Width(80);
                columns.Bound(c => c.LibelleEntreprise  );
                columns.Bound(c => c.Code_Financement   );
                columns.Bound(c => c.CodeDepartement    );
                columns.Bound(c => c.ContactEcole       );
                columns.Bound(c => c.Gestionnaire);
                columns.Bound(c => c.GestDosAdmin       );
                columns.Bound(c => c.StatutDosAdmin     );
            })
            .ToolBar(toolbar =>
            {
                toolbar.Excel();
                toolbar.Pdf();
                toolbar.Search();
            }).Excel(excel => excel.AllPages(true))
            .Height(700)
            .Pageable(pageable => pageable
               .Input(true)
               .Numeric(false)
             )
            .Navigatable().Mobile()
            .Sortable()
            .Scrollable()
            .Resizable(r => r.Columns(true))
            .Reorderable(r => r.Columns(true))
            //.Filterable()
            .Events(e => e.DataBound("onDataBound"))
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
            .DataSource(dataSource => dataSource
                .Ajax()
                .Batch(false)
                .PageSize(500)
                .AutoSync(false)
                .ServerOperation(true)
                .Events(events => events.Error("error_handler"))
                .Model(model =>
                {
                    model.Id(p => p.Id_Inscription);
                    model.Field(p => p.Civilite         ).Editable(false);
                    model.Field(p => p.Nom              ).Editable(false);
                    model.Field(p => p.Prenom           ).Editable(false);
                    model.Field(p => p.Libelle          ).Editable(false);
                    model.Field(p => p.DateDebut        ).Editable(false);
                    model.Field(p => p.DateFin          ).Editable(false);
                    model.Field(p => p.LibelleEntreprise).Editable(false);
                    model.Field(p => p.Code_Financement ).Editable(false);
                    model.Field(p => p.CodeDepartement  ).Editable(false);
                    model.Field(p => p.ContactEcole     ).Editable(false);
                    model.Field(p => p.GestDosAdmin     ).Editable(false);
                    model.Field(p => p.StatutDosAdmin   ).Editable(false);
                    model.Field(p => p.Gestionnaire     ).Editable(false);
                })
                .Read("GetAllFolders", "RechercheDossiers")



$.ajax({
            url: '@Url.Action("GetFiltredFolders", "RechercheDossiers")',
            type: "Post",
            data: { nom, prenom, dateDebut: dateD, dateFin: dateF, sAnticipee, pFormations, financements, gestionnaires },
            traditional: true,
            dataType: 'json',
            async: true,
            success: function (result) {
                searchResults = result;
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert('failed')
            },
            timeout: 30000,
            cache: false
            
        }).done(function () {
            var dataSource = new kendo.data.DataSource({ data: searchResults });
            var grid = $('#Dossiers').data("kendoGrid");
            dataSource.read().then(function () {
                $('#Dossiers').data('kendoGrid').refresh();
            });
            var pageSi = grid.dataSource._pageSize
            grid.setDataSource(dataSource);
            grid.dataSource.query({ page: 1, pageSize: pageSi });
            //grid.refresh();
        });



[HttpPost]
        public async Task<JsonResult> GetFiltredFolders(DateTime? dateDebut, DateTime? dateFin,
            bool sAnticipee, string nom, string prenom, string financements, string pFormations, string gestionnaires)
        {
            string departments = Session["department"].ToString();

            List<Dossier> dossiers = await _conventionDeFormationService.LoadFoldersByAccess(departments, dateDebut, dateFin,
             sAnticipee, nom, prenom, financements, pFormations, gestionnaires);

            return Json(dossiers, JsonRequestBehavior.AllowGet);

        }

3 Answers, 1 is accepted

Sort by
0
Accepted
wajdi
Top achievements
Rank 1
Iron
answered on 07 May 2021, 05:20 PM | edited on 10 May 2021, 09:14 AM

i resolve my problem by oveeriding the jsonresult method but the grid make too much time to reload the result more than 30 seconds. can any one have a solution for this also i want to show the loader for grid to handle this moment of waiting, any suggestion?

 


 protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
        {
            return new JsonResult()
            {
                Data = data,
                ContentType = contentType,
                ContentEncoding = contentEncoding,
                JsonRequestBehavior = behavior,
                MaxJsonLength = Int32.MaxValue
            };
        }

0
wajdi
Top achievements
Rank 1
Iron
answered on 10 May 2021, 12:31 PM

hello,
to display the loader for the grid when loading data, i use this javascript function to handle it.

 


function showloader() {
        $('<div class="k-loading-mask" style="width: 100%; height: 100%; top: 0px; left: 0px;"><span class="k-loading-text">Loading...</span><div class="k-loading-image"></div><div class="k-loading-color"></div></div>').appendTo('#Grid-id .k-grid-content');
       
    };

0
Anton Mironov
Telerik team
answered on 12 May 2021, 10:41 AM

Hello Wajdi,

Thank you for the details and for sharing the resolving approach of the main issue.

In order to use a loading indicator, I would recommend trying the implementation from the following knowledge base article:

Here is a runnable example:

Begin the progress of the loader in the Ajax request and end it in the "success" scope.

I hope this information helps.


Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
wajdi
Top achievements
Rank 1
Iron
Answers by
wajdi
Top achievements
Rank 1
Iron
Anton Mironov
Telerik team
Share this question
or