开发者

JQGrid with Column Reordering

开发者 https://www.devze.com 2022-12-20 19:50 出处:网络
I have a jqgrid and I can reorder my columns with this option in my JQGrid jQuery(\"#list\").jqGrid({ sortable: true,

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

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

This functionality let me reorder A开发者_StackOverflow中文版LL my columns. But I want that some columns must be on fixed places. Is there a way to solve this?

Thanks in advance!

Bruno


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.


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

sortable: {
    exclude: '#'+ grid[0].id +'_actions_buttons'
},


You can set sortable for each column in the colModel

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

Checkout the documentation it's pretty helpful.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消