简体   繁体   English

如何更改 jqgrid 中的行位置?

[英]How to Change Row Location in jqgrid?

I am using jqgrid with MVC and for now, I want change Row location when click on ^ to get one line up and inverse.我正在将 jqgrid 与 MVC 一起使用,现在,我想在单击 ^ 时更改行位置以排列并反转。

actually I want to set 'up' and 'down' signs to every row for change one level row locations实际上我想为每一行设置“向上”和“向下”标志以更改一级行位置

any body can help me?!任何机构都可以帮助我?!

There are a lot of possible solution.有很多可能的解决方案。 One of them is to use custom formtter to define the buttons and then bind event on loadComplete to move the rows using the jquery.其中之一是使用自定义表单来定义按钮,然后在 loadComplete 上绑定事件以使用 jquery 移动行。 Below the code:代码下方:

        $("#jqGrid").jqGrid({
            datatype: "local",
            data: mydata,
            height: 250,
            width: 780,
            colModel: [
                { label :'move', formatter : myformatter, width:95},
                { label: 'Inv No', name: 'id', width: 75, key:true },
                { label: 'Date', name: 'invdate', width: 90 },
                { label: 'Client', name: 'name', width: 100 },
                { label: 'Amount', name: 'amount', width: 80 },
                { label: 'Tax', name: 'tax', width: 80 },
                { label: 'Total', name: 'total', width: 80 },
                { label: 'Notes', name: 'note', width: 150 }
            ],
            viewrecords: true, // show the current page, data rang and total records on the toolbar
            caption: "Load jqGrid through Javascript Array",
            loadComplete : function() {
              $(".up,.down").on('click', function () {
                 var row = $(this).closest("tr.jqgrow");
                 if($(this).is('.up')){
                    row.insertBefore(row.prev());
                 } else {
                    row.insertAfter(row.next());
                 }                    
              });
            }
        });
        function myformatter() {
            return '<button class="up" >Up</button>' + '<button class="down">Down</button>';
        }

Demo here演示在这里

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

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