Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attribute_table_column_filter: take over column width in input elements #61

Open
cxcandid opened this issue Nov 17, 2022 · 0 comments
Open

Comments

@cxcandid
Copy link

The attribute_table_column_filter.js plugin is a highly appreciated extension of LIZMAP. It makes filtering so much easier.

But there is one small issue: The plugin doesn't take over the width of the columns. It uses fixed width for every input element.
attribute_filter_orig

Here's an adapted version that takes column width into account:

lizMap.events.on({
    attributeLayerContentReady: function (e) {
        var cleanLayerName = lizMap.cleanName(e.featureType);

        if ($('#attribute-layer-table-' + cleanLayerName + '_wrapper').data('filtersON') === undefined) {
            // Set flag to add filters only once
            $('#attribute-layer-table-' + cleanLayerName + '_wrapper').data('filtersON', true);

            $('#attribute-layer-table-' + cleanLayerName + '_wrapper thead:first th').not('.sorting_disabled').each(function () {
                var title = $(this).text();
                var width = $(this).width();
                $(this).html('<input type="text" placeholder=" ' + title + '" style="width:' + (parseFloat(width)+20) + 'px" />');
            });

            $('#attribute-layer-table-' + cleanLayerName).DataTable().columns().every(function () {
                var column = this;

                $('input', this.header()).on('keyup change', function () {
                    if (column.search() !== this.value) {
                        column
                            .search(this.value)
                            .draw();
                    }
                }).click(function (e) {
                    // We don't want to sort when users click on the search field
                    e.stopPropagation();
                });
            });
            lizMap.refreshDatatableSize("#attribute-layer-main-" + cleanLayerName);
        }
    }
});

attribute_filter_new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant