2014-09-02 29 views
0

我想拖放列在jqGrid中重新排序。在jqGrid中点击列选择器来拖放列?

我看到了这个Reference page - 这很好,但我想拖拽页面中的列而不点击列选择器按钮拖放或重新排列。

jQuery("#colch").jqGrid({ 
    url: 'server.php?q=2', 
    datatype: "json", 
    colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'], 
    colModel: [{ 
     name: 'id', 
     index: 'id', 
     width: 55 
    }, { 
     name: 'invdate', 
     index: 'invdate', 
     width: 90 
    }, { 
     name: 'name', 
     index: 'name asc, invdate', 
     width: 100 
    }, { 
     name: 'amount', 
     index: 'amount', 
     width: 80, 
     align: "right" 
    }, { 
     name: 'tax', 
     index: 'tax', 
     width: 80, 
     align: "right" 
    }, { 
     name: 'total', 
     index: 'total', 
     width: 80, 
     align: "right" 
    }, { 
     name: 'note', 
     index: 'note', 
     width: 150, 
     sortable: false, 
     hidden: true 
    }], 
    rowNum: 10, 
    width: 700, 
    rowList: [10, 20, 30], 
    pager: '#pcolch', 
    sortname: 'invdate', 
    shrinkToFit: false, 
    viewrecords: true, 
    sortorder: "desc", 
    caption: "Column Chooser Example" 
}); 
jQuery("#colch").jqGrid('navGrid', '#pcolch', { 
    add: false, 
    edit: false, 
    del: false, 
    search: false, 
    refresh: false 
}); 
jQuery("#colch").jqGrid('navButtonAdd', '#pcolch', { 
    caption: "Columns", 
    title: "Reorder Columns", 
    onClickButton: function() { 
     jQuery("#colch").jqGrid('columnChooser'); 
    } 
}); 

任何建议areappreciated。

感谢

回答

1

,您应该使用的jqGrid的sortable: trueoption。您还需要额外包含jQuery UI JavaScript文件(不仅仅是CSS)。

顺便说一句columnChooser不仅允许改变列的顺序,而且主要隐藏/显示列。

+0

非常感谢Oleg .... – 2014-09-02 11:35:18

+0

@KrishnakumarSubbaiyan:不客气! – Oleg 2014-09-02 11:51:01