ColumnControl - custom content

ColumnControl - custom content

chris.durhamchris.durham Posts: 17Questions: 5Answers: 0

Does anyone have a simple example of a columnControl custom content widget. I've got the basics in place to create the button which does what I want (toggle rowgrouping on various fields), but I can't figure out how to integrate that into the dropdown menu's neatly.

The docs say that I can extend 'Button', but I can't see how I do that in the custom content code?

Answers

  • allanallan Posts: 65,058Questions: 1Answers: 10,773 Site admin

    Your best bet here is to take a look at the code for one of the existing buttons. For example this is for orderAsc.

    Worth noting as well that I plan to have a row grouping button in ColumnControl 1.1 which I hope will be out at the end of the month.

    Allan

  • chris.durhamchris.durham Posts: 17Questions: 5Answers: 0

    I looked at one of those, but couldn't figure out how to convert the

    new Button(dt)

    to JS

    :)

  • chris.durhamchris.durham Posts: 17Questions: 5Answers: 0

    Right - engaged brain and I think I've got it sorted :)

  • allanallan Posts: 65,058Questions: 1Answers: 10,773 Site admin

    That is JS :). That class is available under DataTable.ColumnControl.Button and can be instantiated from there. This might be a good one for a blog post sometime... Thanks for bringing this up!

    Allan

  • chris.durhamchris.durham Posts: 17Questions: 5Answers: 0

    Yeah I realized that was my mistake - I needed to get it from the Datatable.ColumnControl module :)

    One further question - is there an equivalent of autoClose:true for the columnControl menus?

  • chris.durhamchris.durham Posts: 17Questions: 5Answers: 0

    And fwiw - knowing its not the most elegant code, but it works and someone might find inspiration...

        DataTable.ColumnControl.content.rowGroup  = {
            defaults: {
                text: 'Clear Grouping',
                column: '',
                className: 'groupDesc',
                icon: 'moveRight'
            },
            init: function (config) {
                var _this = this;
                var dt = this.dt();
                var btn = new DataTable.ColumnControl.Button(dt)
                    .text(config.text)
                    .icon(config.icon)
                    .className(config.className)
                    .handler(function () {
                    _this.dt()
                        .rowGroup().dataSrc(config.column)
                        .draw();
                });
                dt.on('rowgroup-datasrc', function (e, dt, val) {
                    dt.order.fixed({ pre: [[val, 'asc']] }).draw();
                });
                return btn.element();
            }
        };
    
  • allanallan Posts: 65,058Questions: 1Answers: 10,773 Site admin

    One further question - is there an equivalent of autoClose:true for the columnControl menus?

    Not at the moment I'm afraid. However, you can call ._close() on the div.dtcc-dropdown element. That is a custom method that is added to the dropdown elements and will close all of them.

    Allan

  • allanallan Posts: 65,058Questions: 1Answers: 10,773 Site admin

    I think that code look good btw!

    I've been working on ColumnControl 1.1 features recently, which includes a new rowGroup button and this is my attempt at it. There are also buttons for adding and removing subgroups and clearing all.

    Allan

  • cdrudgecdrudge Posts: 2Questions: 0Answers: 0

    Is there a timeline for when ColumnControl 1.1 will be available, either as a nightly or as a full release? I was looking for that exact additional functionality when I came across this thread.

    I'd love to not reinvent the wheel if it's already invented. If it won't be for a while, that's fine, I'd just like to know when that might be.

  • allanallan Posts: 65,058Questions: 1Answers: 10,773 Site admin

    Hopefully tomorrow, all being well :).

    Allan

Sign In or Register to comment.