1

I'm developing a webpage where users can filter data and then export the selection to pdf or excel. The website is using ASP .NET C#.

To filter the data I have crated a webpage containing a left column with boxes and drop downs enabling users to enter search criteria and then click a search button. This is the typical search/filter functionality that a lot of websites contains. After filtering the data, the selecting is displayed using an asp listview. This listview generates a table. I've implemented Dragtable, enabling users to alter the sequence of the columns in this table, and also the columnManager enabling users to select which columns to display.

So my problem is that the filter/search functionality is resolved back-end using asp .net C#, while the selecting and rearranging of columns is done client-side using jQuery. When users now click the "export"-button, I'd like to collect the filter done by the asp controls in addition to the filter done by jQuery, and create the file. This file should only contain the columns selected using columnManager, in the same order they are in after being altered using dragtable.

What is best practice when using both server side filter and client side filter? I've also considered to drop all of the server-side filtering and use only ajax.post() to send all filters in JSON format to the server. I also want to enable users to save their current filter for another time.

Update

I've decided to drop the server side and use ajax (getJSON to be more precisely) to get the search result. This way I don't loose the ordering and sorting of columns that is done with jQuery/js, which I would with a post-back (could use cookies'n stuff, of course). I also keep all the logic in one place, and JSON objects can easily be wrapped/unwrapped server-side. Thanks for your answers, though!

4

2 回答 2

0

让客户端和服务器端在同一个地方工作一点也不坏。世界上运行的所有优秀应用程序都有这些组合。

但是,我们需要看到方法。

如果您不想要任何回发,我建议您使用 Jquery。

如果您对往返没问题,请继续使用服务器端和 Ajax。

于 2012-10-26T10:20:58.187 回答
0

您的方法还有另一个问题:如果用户先订购列然后过滤它会发生什么?列的顺序被重置。

但是,使用 jquery ui 可拖动,您可以触发 ajax 调用以通知服务器端代码有关更改。您可以将函数绑定到停止事件:http ://api.jqueryui.com/draggable/#event-stop

所以我会做以下事情:

  • 当用户更改列的顺序时触发 ajax 调用,但不刷新数据
  • 当用户添加过滤器并刷新数据时触发 ajax 调用

服务器端代码始终是最新的,并在必要时呈现正确的输出。

于 2012-10-30T10:27:28.733 回答