javascriptjquerybuttonjqgridcolumn-chooser

Add custom button into jqGrid ColumnChooser dialog


i want to add custom button into ColumnChooser dialog box and make it to behave like others. I try to get something like this(Default button)

  _this.table.jqGrid("navButtonAdd", _this.pid, {
    caption: "",
    buttonicon: "icon",
    title: "Title",
    onClickButton: function() {
      return self.table.jqGrid("columnChooser", {
        done: function(perm) {
          if (perm) {   
            self.table.jqGrid("remapColumns", perm, true);
            return $(window).triggerHandler("resize.jqGrid");
          }
        },
        dialog_opts: {
          modal: true,
          resizable: false
        },
        msel_opts: {
          dividerLocation: 0.5
        },
        width: 460
      });

    }
  });

Solution

  • You can do this in the following way:

    onClickButton: function () {
        $(this).jqGrid("columnChooser", {
            dialog_opts: {
                buttons: {
                    Default: function () {
                        alert("Default button is clicked!");
                    }
                }
            }
        });
    }
    

    The corresponding demo displays the following results:

    enter image description here