Metro 4 Select limits for options

Get help with using Metro 4 components
Post Reply
bambirra
Posts: 7
Joined: Mon Aug 13, 2018 6:20 pm
Status: Offline

Metro 4 Select limits for options

Post by bambirra » Thu Aug 16, 2018 9:19 pm

Hi,
I'm using the Metro 4 Select component and noticed that there is a limit of 85 options.

I load my select with a JSON object by ajax. When my return has more than 85 items these are not loaded by the component.

Loading code:

Code: Select all

                
$.get({
	url: servidor + 'assets/listslct/rh_setores_id', 
		cache: false
}).then(function(response){
	var select  = $('#rh_setores_id').data('select');
	select.data(response);
});
screenshot developer console
Image


screenshot developer inspector
Image

drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

Post by drodriguez » Sat Aug 18, 2018 12:07 am

can you create and example in https://codepen.io/ for help you?

bambirra
Posts: 7
Joined: Mon Aug 13, 2018 6:20 pm
Status: Offline

Post by bambirra » Wed Aug 22, 2018 11:35 pm

Sorry for the delay in responding.

I've replicated the error in this codepen as you requested.
https://codepen.io/bambirra/project/editor/XRaPOL

I found the error. The option 47 is 'Item.47' and this dot in the option throws an exception, when I change the option to 'Item 47' it works.

drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

Post by drodriguez » Thu Aug 23, 2018 5:14 pm

Hi bambirra.

I don't know why, or how do you have your json in real live, but, in codepen.io example you have Item dot 47 and Item dot 48 :

"47": "Item.47",
"48": "Item.48"



edit: the problem is not the items quantity.... if you remove the dots the example work.

Let me know what happen in real world.

bambirra
Posts: 7
Joined: Mon Aug 13, 2018 6:20 pm
Status: Offline

Post by bambirra » Thu Aug 23, 2018 6:34 pm

Hi drodriguez,

In the example, I put the dots in the options 47 and 48 to exemplify.

In the real world I have 147 options and in some have dots, like to items 47 and 48 of the example. These dots generate an exception and do not complete the loading of the options.

part of JSON in production:

Code: Select all

{
...
 "81": "DEPARTAMENTO PESSOAL",
 "82": "ENCARTE",
 "83": "ESCRITORIO - BETIM",
 "84": "ESCRITORIO - DC",
 "85": "FER.1",
 "86": "FER.2",
 "87": "FER.1.2",
 "88": "FER.1.3",
 "89": "FER.1.4",
 ...
}
Realy if I remove the dots of the options it works, but these dots are part of the text of the option.

Then I'll run some tests to see if this limitation is on the Select component of Metro 4 or Jquery.

Thank´s for your help.

drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

Post by drodriguez » Thu Aug 23, 2018 9:37 pm

ok... then the real question is:
"how load select dynamic by json with dots"

I suggest you create new question into the forum with a new codepen.io simple sample with 5 or 10 item with dots and waiting olson answer.

drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

Post by drodriguez » Thu Aug 23, 2018 9:45 pm

other way is not pass json to select....
do a for each json and create a html string with options something like:

var html = "";
$.each(jsonData,function(key, value)
{
html += '<option value=' + key + '>' + value + '</option>';
});

var select = $('#select1').data('select');
select.data(html);

for debug use: https://cdn.metroui.org.ua/v4/js/metro.js (not min.js)
line 14297
if (typeof op === 'string') {
element.html(op);
} else if (Utils.isObject(op)) {
$.each(op, function(key, val){
if (Utils.isObject(val)) {

Post Reply