简体   繁体   English

如何使用Jquery重新排序Gridview行?

[英]How to reorder Gridview rows using Jquery?

I am using Drag and Drop for sorting rows of grid, 我正在使用拖放功能对网格的行进行排序,

In this process i want Order(Sequence) of dragged row to be changed dynamically like if i drag 3rd row to 1st place i want it(order) to change to 1 dynamically. 在此过程中,我希望拖动行的顺序(序列)可以动态更改,就像我将第三行拖动到第一位一样,我希望它(顺序)可以动态更改为1。

I am not getting any idea of how to loop and change order dynamically. 我对如何动态循环和更改订单一无所知。

var SortedIDs = "";
$(".gvSortPorts").find("tbody > tr").each(function () {
    SortedIDs += $(this).attr("id") + "1";
});

Can any one please help in giving idea, i want it acheive using jquery. 任何人都可以帮忙提出想法,我希望它能使用jquery实现。

Add the following JQuery and Tablesorter javascript files references inside page head section. 在页面标题部分内添加以下JQuery和Tablesorter javascript文件引用。

<script src="scripts/jquery-1.4.3.min.js" type="text/javascript"></script>
<script src="scripts/jquery.tablesorter.min.js" type="text/javascript"></script>

Finally call the tablesorter function on gridview to make your gridview sortable. 最后,在gridview上调用tablesorter函数以使您的gridview可排序。

<script type="text/javascript">
   $(document).ready(function() {

      $("#GridView1").tablesorter();

   });
</script>

Reference: 参考:

http://www.ezzylearning.com/tutorial.aspx?tid=2168345 http://www.ezzylearning.com/tutorial.aspx?tid=2168345

For Drag And Drop: 对于拖放:

http://forums.asp.net/t/1615668.aspx/1 http://forums.asp.net/t/1615668.aspx/1

Hope its helpful. 希望对您有所帮助。

There are number of jquery plugin available for sorting: 有许多可用于排序的jquery插件:

i have use Datatable which provide you a way which will help you alot. 我已经使用了数据表 ,它为您提供了一种可以帮助您的方法。 you can do customization as you want and it provides number of features like pagging, search, sorting etc. 您可以根据需要进行自定义,并且它提供了很多功能,例如分页,搜索,排序等。

Hope this will resolve your problem. 希望这能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM