JQGrid with Column Reordering

前端 未结 4 1438
难免孤独
难免孤独 2021-01-06 11:53

I have a jqgrid and I can reorder my columns with this option in my JQGrid

    jQuery(\"#list\").jqGrid({
                sortable: true,
                ...         


        
相关标签:
4条回答
  • 2021-01-06 12:42

    You can set sortable for each column in the colModel

    colModel: [{ name: 'name', index: 'name', sortable: true },...
    

    Checkout the documentation it's pretty helpful.

    0 讨论(0)
  • 2021-01-06 12:48

    This ain't possible in jqgrid. I searched also a long time for this. And everything i tried failed.

    0 讨论(0)
  • 2021-01-06 12:50

    Never say never. jqGrid uses jQueryUI's Sortable class to perform the column drag-n-drop function. http://jqueryui.com/demos/sortable/

    To remove a column from the list of sortable columns, run these two commands after you've rendered your grid (with sortable: true).

    // disable the sortable property on your target element 
    // (which was applied when jqGrid rendered the grid)
    $('tr.ui-jqgrid-labels').sortable({ cancel: 'th:#element_id'});
    // update the list of sortable item's, and exclude your target element
    $('tr.ui-jqgrid-labels').sortable({ items: "th:not(#element_id)" });
    

    Note: This works best if your unsortable columns are on the left or right edge of the grid. Otherwise, you will still be able to re-sort other columns around them.

    Also: Make sure you understand the difference between the two sortable options (grid level and colmodel level). On the grid options, "sortable: true" means the columns can be reorders by drag-and-drop. On the colmodel options, "sortable: true" means that you can reorder the rows by clicking on the column's header. Setting sortable to true on the grid options will not cascade down to the colmodel options. However, on the colmodel sortable is true by default.

    0 讨论(0)
  • 2021-01-06 12:52

    Now in 2013 you can define the "exclude" parameter of "sortable" , like this :

    sortable: {
        exclude: '#'+ grid[0].id +'_actions_buttons'
    },
    
    0 讨论(0)
提交回复
热议问题