var options = "<option></option>"; for(var i=0; i < columns.length; i++) { if( columns[i].data != null && columns[i].data != undefined) { options += "<option value='"+ i +"' > "+ columns[i].data +" </option>"; } }$('#role').html(options);
Hi,Please refer to the official Select2 Docs to programmatically control Select2.Regards.
Please enter your email and we will send a link to your email to reset your password