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

Grid paging

6 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
iliya
Top achievements
Rank 1
Veteran
iliya asked on 25 Dec 2020, 08:18 AM

Hello

I am trying to  implement kendo grid,

I see all the data in grid but when i move to next page all the data is deseapers.

This is my controller code

  public async Task<ActionResult> TodaysSalesList([DataSourceRequest] DataSourceRequest request, DateTime? fileDate, int? pageSize, int? pageNo, int? loanCustomerId)
        {
            PagedResults<VmpLoanSalesVM> resultloans;
            try
            {
                var startDate = fileDate.GetValueOrDefault().Date;

                var dic = new DualControlDictionary
                {
                    { "date", startDate.Date.ToString() },
                    { "loanCustomerId", loanCustomerId.ToString() }
                };
                resultloans = await _dualControlService.GetData(dic);   
                var jsonRes = Json(resultloans.Results.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                jsonRes.MaxJsonLength = int.MaxValue;
                return jsonRes;
            }
            catch (Exception e)
            {
                Log.Error(e);
                return Json(new
                {
                    success = false
                }, JsonRequestBehavior.AllowGet);
            }
        }

I have also tried return the data like this 

 var jsonRes = Json( new {Data=resultloans.Results.ToDataSourceResult(request),Total=esultloans.ResultsCount()}, JsonRequestBehavior.AllowGet);
                jsonRes.MaxJsonLength = int.MaxValue;
                return jsonRes;

But it doesn't help

See attched file my grid cshtml

6 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 28 Dec 2020, 12:55 PM

Hi Iliya,

I examined the provided code, and unfortunately, I am not able to see any parts that might cause the described faulty behavior. 

As there is a lot of code, I might have missed something. Having said that, it will help me a lot to provide assistance to the best of my knowledge if you can send me a sample project that clearly replicates and isolates the issue. I will use this project to eventually find a workaround.

I look forward to hearing from you.

 

Regards,
Preslav
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/.

0
iliya
Top achievements
Rank 1
Veteran
answered on 02 Jan 2021, 11:00 PM

Hi

Thank you for answer i have figured it about there was some databinding issues the caused the error ,

I have anther  question i have two grids i am using mvc razor pages,so in regular view save to excel works fine but when i use grid in partial view the export excel saves empty file only columns 

0
iliya
Top achievements
Rank 1
Veteran
answered on 02 Jan 2021, 11:22 PM

this i smy code regarding exle emty file

     @(Html.Kendo().Grid<VampirePortal.Data.Reports.Summary>()
            .Name("SummaryGrid")
            .Selectable()
            .Columns(columns =>
            {

                columns.Bound(c => c.Mpl);
                columns.Bound(c => c.SucssesfulLoans).Title("Sucssesful Loans");
                columns.Bound(c => c.FailedLoans).Title("Failed Loans");


            })
            .ToolBar(toolbar =>
            {
            //toolbar.Excel();
                toolbar.Template(@<text>
                        <div style="display: block; float: right">
                            <a  id="myexport" class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export</a>
                        </div>
                </text>);
            })
            // Set grid sortable.
            .Sortable()
            // Set grid pagable.
            .Pageable(pageable =>
            {
                pageable.Refresh(false);
                pageable.PageSizes(true);
            })
            .Excel(excel => excel
            .FileName("User Action Report" + DateTime.Now + ".xlsx")
            .Filterable(true)
            .AllPages(true)
            .ProxyURL(Url.Action("Excel_Export_Save", "Sales"))
            )
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model =>
                {
                    model.Id(emp => emp.Mpl);
                    model.Field(emp => emp.SucssesfulLoans).Editable(false);
                    model.Field(emp => emp.FailedLoans).Editable(false);

                }
                )
                .Read(read => read.Action("Summary", "Sales", new { id = @Model.Id }))
                )
            )
    </div>

0
Preslav
Telerik team
answered on 05 Jan 2021, 12:41 PM

Hello Iliya,

I tested the scenario by creating a project with a Grid in a partial view in an ASP.NET Core Razor Pages project. On my side, the Grid is exported as expected. Please, find the attached project to this post.

The only difference is the proxy URL. Could you please confirm that the proxy is handling the request correctly?

 I look forward to your reply

 

Regards,
Preslav
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/.

0
iliya
Top achievements
Rank 1
Veteran
answered on 05 Jan 2021, 12:54 PM

Thx for replay will check ,

can u pls explain about the proxy purpose?

BTW your project is net core mine is asp net is there is any difference on kedno behavior?

0
Preslav
Telerik team
answered on 06 Jan 2021, 11:55 AM

Hi Iliya,

About the proxy, The URL of the server-side proxy will stream the file to the end-user. A proxy will be used when the browser isn't capable of saving files locally. Such browsers are IE version 9 and lower and Safari. The developer is responsible for implementing the server-side proxy. The relevant API reference is available here: https://docs.telerik.com/aspnet-mvc/api/Kendo.Mvc.UI.Fluent/GridExcelBuilder#proxyurlsystemstring

Further, I created the ASP.NET Core Razor Pages project due to the following part of your last post: "I am using mvc razor pages". Razor pages are only available in Core projects - https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-5.0&tabs=visual-studio

However, the regular ASP.NET MVC implementation should look similar to the one from my last reply.

 

Regards,
Preslav
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
iliya
Top achievements
Rank 1
Veteran
Answers by
Preslav
Telerik team
iliya
Top achievements
Rank 1
Veteran
Share this question
or