At http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods there are instructions for building a jqGrid column chooser ('dlog_opts is either an option object to be passed to “dlog”, or (more likely) a function that creates the options object. The default produces a suitable options object for ui.dialog'), but not complete working code; no example is provided of the function that is required.
Is there a complete working example for building a jqGrid column chooser that will allow hiding, showing, and moving columns?
Look at the old example from the answer. The example is mostly about another subject, but in the navigator bar you can see the "column chooser" button. Clicking on the button display column chooser dialog. You can drag any column name from the dialog and drop it on another location to change the column order. You can click on "-" to hide the column and drag any column from the list of hidden columns and drop it on in the list of visible columns.
To reproduce the behavior you should first be sure that during jqGrid downloading you have "jQuery UI addons" (grid.jqueryui.js
) selected. Then you should follows the steps:
include ui.multiselect.css
from the plugins subdirectory of jqGrid 4.0 source.
include jQuery UI jquery-ui.min.js
(not only jquery-ui.css
needed typically for jqGrid)
include ui.multiselect.js
after the jquery-ui.min.js
add new button which call the column chooser
The code can be like the following
var grid = $('#list');
grid.jqGrid ('navButtonAdd', '#pager',
{ caption: "", buttonicon: "ui-icon-calculator",
title: "Choose Columns",
onClickButton: function() {
grid.jqGrid('columnChooser');
}
});
UPDATED: The answer contains description of some additional customization of columnChooser
based on my suggestion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With