question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data-size does not work

See original GitHub issue

I have an issue while using the plugin. My problem is that when I am searching for items and there are big amount of results , vertical scrolls are not appearing. I have data-size set to 10 and it works only after I close and reopen the drop down list. Please help.

` 
$('#ddlLocation')
        .selectpicker({
        })
        .ajaxSelectPicker({
            ajax: {
                url: '@(Url.RouteUrl("Search"))',
                type: "POST",
                dataType: "json",
                data: function () {
                    var params = {
                        Filter: '{{{q}}}',
                        CountryName: 'USA'
                    };

                    return params;
                }
            },
            locale: {
                emptyTitle: 'Search for Location...'
            },
            preprocessData: function (data) {
                var i, l = data.length,
                    arr = [];
                if (l) {
                    for (i = 0; i < l; i++) {
                        if (data[i].Location.toLowerCase().indexOf(this.plugin.query) != -1 || data[i].Location.toLowerCase().indexOf(this.plugin.query) != -1) {
                            arr.push($.extend(true, data[i], {
                                text: data[i].Location,
                                value: data[i].ID,
                                disabled: false
                            }));
                        }
                    }
                }

                return arr;
            },

            preserveSelected: false,`

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marcusfritzecommented, Aug 31, 2018

if fixed it by adding a setTimeout:

preprocessData: function (data) {

var arrayData = [];

[...]

setTimeout(function () {
$('#idOfSelect').selectpicker('setSize');
}, 1);

return array;
}
0reactions
pppdnscommented, Feb 10, 2017

The issue is here in bootstrap-select: https://github.com/silviomoreto/bootstrap-select/blob/v1.12.2/js/bootstrap-select.js#L1012

} else if (this.options.size && this.options.size != 'auto' && this.$lis.not(notDisabled).length > this.options.size) {

with this part of the code: this.$lis.not(notDisabled).length > this.options.size

If using the size option and populating the options AFTER the initialization (e.g. using AJAX) the dropdown’s max height won’t be set and it will have no max height because this.$lis.not(notDisabled).length > this.options.size is false at that time as this.$lis.not(notDisabled).length will be 0 and it’s greater than this.options.size.

So this part won’t run at all:

        $menu.css({
          'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px',
          'overflow': 'hidden',
          'min-height': ''
        });
        $menuInner.css({
          'max-height': menuHeight - menuPadding.vert + 'px',
          'overflow-y': 'auto',
          'min-height': ''
        });

https://github.com/silviomoreto/bootstrap-select/blob/v1.12.2/js/bootstrap-select.js#L1028

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring DataSize class not found
Problem is mismatching Spring Boot (2.1.8.RELEASE) and Spring Core (5.0.12) versions. Core is 5.0.12, because it is transitive dependency of ...
Read more >
configprops endpoint does not display DataSize properties ...
configprops endpoint does not display DataSize properties ... It looks like there is also a problem with inputs as the output above was ......
Read more >
[SERVER-58358] Datasize command does not validate the ...
the command is still executed on the entire collection, so there is no validation of what the user was really intending to do,...
Read more >
DataSize (Spring Framework 6.0.3 API)
This class models data size in terms of bytes and is immutable and thread-safe. ... as 12MB using the specified default DataUnit if...
Read more >
db.collection.dataSize()
Returns: The size in bytes of the collection. Data compression does not affect this value. Starting in MongoDB 4.4, to run ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found