Closed Sherif-E-Saleh closed 8 years ago
you should first create a "select2" filter type
(function (window, document) {
var factory = function ($, ColumnFilter) {
'use strict';
ColumnFilter.filter.select2 = {
dom: function (th) {
var self = this, select;
select = $('<select>').append('<option></option>');
select.addClass(self.options.cssClass);
$.each(self.options.values, function (ii, value) {
$('<option>').val(value.value).text(value.label).appendTo(select);
});
self.elements = select.appendTo(th);
if (typeof self.options.width !== 'undefined') {
self.elements.css('width', self.options.width);
} else {
self.elements.css('width', '100%');
}
self.elements.select2(self.options.config);
return self.elements;
},
bindEvents: function () {
var self = this;
self.elements.on('select2:select', function () {
self.search();
});
},
request: function () {
var self = this;
return self.elements.val();
}
};
};
// Define as an AMD module if possible
if (typeof define === 'function' && define.amd) {
define(['jquery', 'datatables-light-columnfilter'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery'), require('datatables-light-columnfilter'));
} else if (jQuery) {
// Otherwise simply initialise as normal, stopping multiple evaluation
factory(jQuery, jQuery.fn.dataTable.ColumnFilter);
}
})(window, document);
and then
vm.dtOptions1 = DTOptionsBuilder.fromFnPromise(function() {
(...)
.withLightColumnFilter({
(...)
'5':{
type: 'select2',
config: {
[select2 configuration object]
}
values:[
{
value:'Active',
label:'Active'
},
{
value:'Inactive',
label:'Inactive'
}
]
})
Hey Sherif-E-Saleh, did this work for you?
Yeah it's been helpful ao far, thank you melino :) will inquiry about more issues should I face any other.
-----Original Message----- From: "melino" notifications@github.com Sent: 22/07/2016 13:07 To: "thansen-solire/datatables-light-columnfilter" datatables-light-columnfilter@noreply.github.com Cc: "Sherif E.Saleh" shrfsaleh@gmail.com; "Manual" manual@noreply.github.com Subject: Re: [thansen-solire/datatables-light-columnfilter] How to enableselect2 in the dropdown filter (#4)
Hey Sherif-E-Saleh, did this work for you? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Using Angular-Datatables, I am going through a case in my project that I need to use select2 instead of the regular select in the select supported by light-column filter?
Here is how I include the select in the filter.
`