如何将大量模型数据绑定到mvc中的html表中 [英] How to bind large number of model data into html table in mvc

查看:126
本文介绍了如何将大量模型数据绑定到mvc中的html表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我正在尝试将模型数据绑定到我的mvc应用程序中的html表中,并能够在几秒钟内获取UI中的数据。但是当记录超过25k时,绑定需要15-20秒。



以下是我的代码:



cshtml:

Dear All,

I am trying to bind the model data into html table in my mvc application and able to get the data in UI in fraction of seconds. But when the records are more than 25k, it takes 15-20 seconds to bind.

Below is my code :

cshtml :

<tbody id="faultydevice-container">
            @foreach (FaultHandlingReportFaultyDeviceDataViewModel device1 in Model.FaultyDevices)
            {
                <tr>
                    <td>
                        @device1.status
                    </td>
                    <td>
                        @device1.pointAddress
                    </td>
                    <td>
                        @device1.Description                       
                    </td>
                    <td>
                        @device1.eventTime
                    </td>
                    <td>
                        @device1.eventResetTime
                    </td>
                </tr>
            }
        </tbody>





注意:我没有使用实体框架来获取数据。相反,只需调用存储过程将记录绑定到列表中。即,使用ORM



任何人都可以建议将大量数据绑定到html表的方法吗?



在此先感谢,



Note : I am not using entity framework to get the data. Instead, just calling the stored procedure to bind the records into a list. i.e., using ORM

Can anyone please suggest the way to bind huge data into html table ?

Thanks in advance,

推荐答案

创建大型表总是很慢。如果用户在每个行上花费3秒钟,则需要20个小时来处理整个表,因此您显然会生成很多用户忽略的无意义数据。没有快速的方法来做你想做的事情,而是你应该实现paging\filtering\searching,这样用户只能看到他们感兴趣的数据,或者你必须至少给他们数万行如果他们对其余部分不感兴趣,只能看第一页。
Creating large tables is always going to be slow. If a user spent 3 seconds on each of your rows it would take 20 hours to process the whole table, so you are obviously generating a lot of meaningless data the user ignores. There is no fast way to do what you want to do, instead you should implement paging\filtering\searching so that users only see the data they are interested in, or if you must give them tens of thousands of rows they at least only see the first page if they're not interested in the rest.


这篇关于如何将大量模型数据绑定到mvc中的html表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆