当你应该从HTML切换到服务器端表处理

当你应该从HTML切换到服务器端表处理

本文介绍了网格 - 当你应该从HTML切换到服务器端表处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,这个问题可能是主观的,但很多网格的javascript插件都出来帮分页和排序表。他们通常工作在两种方式,第一,最简单的是,它需要现有的HTML <表> ,并将其转换成一个排序和搜索信息。第二个是,它传递信息到服务器,并具有服务器选择信息从要显示的数据库

,This question is likely subjective, but a lot of "grid" javascript plugins have come out to help paginate and sort tables. They usually work in 2 ways, the first and simplest is that it takes an existing HTML <table> and converts it into a sortable and searchable information. The second is that it passes info to the server and has the server select info from the database to be displayed.

我的问题是这样的:在什么时候(大小明智的)是更有效地使用服务器端处理VS显示所有的数据,并有网格插件将其转换为可排序/搜索表客户端 - 一面?

使用数据表作为一个例子,我必须执行至少3个查询得到总行该表中,总过滤结果分页,将过滤的结果要被显示为特定的选定的页。每当我排序,我查询了。每次我移动到另一个页面,或在表中搜索,更多的查询。

Using datatables as an example, I have to execute at least 3 queries to get total rows in the table, total filtered results for pagination, and the filtered results to be displayed for the specific selected page. Then every time I sort, I am querying again. Everytime I move to another page, or search in the table, more queries.

如果我是拉一旦数据时,客户端访问的页面,我会执行一个查询,然后格式化,结果推到客户端的一次。这增加了页大小,并且可能延迟了页面的加载一旦变得太大。有利的一面是将只有一个查询,所有的排序,搜索和分页是由插件处理的,所以没有等待响应,也没有更多的疑问。

If I was to pull the data once when the client visits the page, I would be executing a single query, and then formatting and pushing the results to the client all at once. This increases the page size, and possibly delays loading of the page once it gets too big. The upside is there will only one query, and all the sorting, searching, and pagination is handled by the plugin, so no waiting for a response and no more queries.

如果我有只有几行,我想只是格式化的表格数据推到客户端的页面加载将是最快的。但与数千行,切换服务器端将是最有效的方式。

If I was to have just a few rows, I imagine just pushing the formatted table data to the client at the page load would be the fastest. But with thousands of rows, switching to server-side would be the most efficient way.

在哪里引爆点?有没有一个临界点,或者说是服务器端或客户端的方式去的时候100%?

Where is the tipping point? Is there a tipping point, or is server-side or client-side the way to go 100% of the time?

推荐答案

这是你的问题的答案只能是主观的。所以,我将解释如何,我个人理解这个问题,并给我建议。

The answer on your question can be only subjective. So I explain how I personally understand the problem and give me recommendation.

在我看来,用2-3行和3-4列中的数据可以不使用任何插件显示在HTML表。你显示该用户的数据的更重要的将是,用户将能够以把握将要显示的信息。所以,我认为信息,例如必须是良好的格式化并标有颜色和图标的例子。这有利于从大概10行数据掌握的信息,但没有更多。如果你只是显示表100行或更多,那么你的负担过重用户。用户将要分析的数据来从表中的任何有用的信息。滚动的数据,使这个不容易。

In my opinion the data with 2-3 row and 3-4 column can be displayed in HTML table without usage any plugin. The data you display for the user the more important will be that the user will be able to grasp the information which will be displayed. So I think that the information for example have to be good formatted and marked with colors and icons for example. This with help to grasp information from probably 10 rows of data, but not much more. If you just display table with 100 rows or more then you overtax the user. The user will have to analyse the data to get any helpful information from the table. Scrolling of the data makes this not easier.

所以我认为应该给用户舒适的,或者至少方便的界面的进行排序和过滤的从表中的数据。确切的接口主要是品味的问题。例如网格可以有额外的过滤杆

So I think that one should give the user comfortable or at least convenient interface to sort and to filter the data from the table. The exact interface is mostly the matter of taste. For example the grid can have an additional filter bar

有关的过滤,甚至对数据进行排序有没有纯粹的字符串,但要能区分数据类型,如整数这一点很重要(10应为9后,而不是1和2之间),数字数内(正确的跨preT'。'和','),日期 2012年3月20号应刨丝器为 4/15/2010 )等。如果你只是转换 HTML表格的一些网格,将有问题的正确的筛选或排序。即使你用纯的本地的JavaScript的数据网格显示有数据源有某种类型的信息,这将是重要的,然后创建一个基于数据网格中。在这种情况下,你可以给出日期的JavaScript 日期或ISO 8601字符串2012-03-20,并在网格中显示的数据对应的指定格式为 2012年3月20日 20-MAR-2012

For filtering and even for sorting of the data it's important to have not pure strings, but to be able to distinguish the data types like integer (10 should be after 9 and not between 1 and 2), numbers (correct interpret '.' and ',' inside of numbers), dates (3/20/2012 should be grater as 4/15/2010) and so on. If you just convert HTML table to some grid you will have problems with correct filtering or sorting. Even if you use pure local JavaScript data to display in grid it would be important to have datasource which has some kind of type information and then to create the grid based in the data. In the case you can gives date as JavaScript Date or as ISO 8601 string "2012-03-20" and in the grid display the data corresponds the specified formatter as 3/20/2012 or 20-Mar-2012.

无论是实施在服务器端还是在客户端过滤,排序和分页不是谁打开页面的用户非常重要。重要的是只有一切工作的速度不够快。确切的选择网格插件,过滤(带过滤器的工具栏或外部控制)和电网的造型取决于你的品位和项目的需求。

Whether you implement filtering, sorting and paging on the server side or on the client side is not really important for the user who open the page. It's important only that all works quickly enough. The exact choose of the grid plugin, the filtering (with filter toolbar or external controls) and styling of the grid depend on your taste and the project requirements.

这篇关于网格 - 当你应该从HTML切换到服务器端表处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:26