【问题标题】:Problem while uploading 10000 data to Devextreme datagrid in ASP.NET MVC在 ASP.NET MVC 中将 10000 个数据上传到 Devextreme 数据网格时出现问题
【发布时间】:2021-03-22 19:48:34
【问题描述】:

我在 asp.net Mvc 中使用 devextreme 数据网格。当我处理 5000 个数据时,Datagrid 工作正常。但是当我想处理10000条数据时,无法加载数据,内部服务器报错。

我的 index.cshtml;

<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header col-dark-green">
            Barsan Portal <small>Gönderici/Alıcı</small>
        </h1>
        <div class="demo-container">
            <div id="gridContainer" style="height:800px"></div>
        </div>
    </div>
</div>

我的 index.js :

 $(function () {

            var dataSource = new DevExpress.data.DataSource("/Nakliye/GetGondericiAlicilar");
            console.log(dataSource);
            $("#gridContainer").dxDataGrid({
                dataSource: new DevExpress.data.CustomStore({
                    key: "kodu",
                    pageSize:50,
                    loadMode: "raw", // omit in the DataGrid, TreeList, PivotGrid, and Scheduler
                    load: function () {
                        return $.getJSON("/Nakliye/GetGondericiAlicilar")
                            .fail(function () { throw "Data loading error" });
                    }
                }),
                selection: {
                    mode: 'multiple'
                },
                renderAsync: true,
                allowColumnReordering: true,
                allowColumnResizing: true,
                cellHintEnabled: false,
                columnResizingMode: "nextColumn",
                showBorders: true,
                searchPanel: {
                    visible: true,
                    width: 240,
                    placeholder: "Ara..."
                },
                headerFilter: {
                    visible: true,
                },
                filterPanel: {
                    visible: true
                },
                filterRow: {
                    visible: true
                },
                loadPanel: {
                    enabled: true
                },
                groupPanel: {
                    visible: true,
                    placeholder: "Bir sütun başlığını o sütuna göre gruplandırmak için buraya sürükleyin"
                },
                pager: {
                    showPageSizeSelector: true,
                    allowedPageSizes: [10, 20, 50, 100, 200],
                    showNavigationButtons: true,
                    showInfo: true,
                    infoText: "Sayfa {0} / {1} ({2} öğe)" 
                },
                columns: [{
                    dataField: "adi",
                    caption: "Adı"
                }, {
                    dataField: "Adres",
                }, {
                    dataField: "il",
                    width: 115,
                    caption: "İl"
                }, {
                    caption: "Ülke",
                    dataField: "ulke",
                }, {
                    caption: "Posta Kodu",
                    dataField: "postakodu",
                    width: 115,
                }, {
                    caption: "Telefon",
                    dataField: "telefon",
                    width: 155,
                }, {
                    caption: "Faks",
                    dataField: "faks",
                    width: 155,
                }, {
                    caption: "İlgili",
                    dataField: "ilgili",
                    width: 195,
                }]
            });
        });

关于操作的我的控制器:

 public ActionResult GetGondericiAlicilar() { return Json(_nakliyeService.GetGondericiAlicilar(), JsonRequestBehavior.AllowGet); }

GetGondericiAliciler() 在我的服务中:

 public List<gnladresbankasi> GetGondericiAlicilar()
        {
            var result = _objectRawSql.Execute(StaticParams.Connstr, typeof(gnladresbankasi),
                //sql functions 
                @"Select top 10000 kodu, adi, adres1 + ' ' + adres2 AS Adres, il, (select adi from gnlulke where kod = ulke) AS Ulke, postakodu, telefon, fax, ilgili
                FROM gnladresbankasi ab WHERE Exists(select * from gnlFirmaGondericiAlici ga WHERE ab.kodu = ga.GondericiAliciKodu)").Cast<gnladresbankasi>().ToList();
            
            return result;

        } 

正如我所说,5000 条数据效果很好,但是当有 10000 条数据时,加载图标返回,数据没有加载。 是否应针对大数据采取特别行动?

【问题讨论】:

  • 欢迎来到 SO。请为您的问题选择正确的标签。不涉及 C 代码。是 C# 还是 C++ 还是其他?请编辑您的问题以相应地修复标签。
  • 我看到您的控制器代码没有任何分页功能。这会导致网格的填充非常耗时。您可以使用 DevExtreme 的内置 DataSourceLoadOptions 类将分页数据从前端传递到项目的后端。

标签: c# jquery json asp.net-mvc devextreme


【解决方案1】:

在浏览器网络标签中发现如下错误;

“/”应用程序中的服务器错误。 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了 maxJsonLength 属性中设置的值。 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Can I set an unlimited length for maxJsonLength in web.config 这解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多