stateSave not working with Select2 when using server-side ajax filtering
thomark1 opened this issue · 1 comments
thomark1 commented
When stateSave is enabled, the filter is set to "select2" and data are retrieved with ajax, the filter is not properly set after page reload.
chrome_yeBc3dPQEL.mp4
{
column_number: 10,
select_type: "select2",
select_type_options: {
width: '100%',
language: "{{ config('app.locale') }}",
placeholder: '@lang('global.choose')',
dropdownAutoWidth: true,
allowClear: true,
theme: 'bootstrap-5',
minimumInputLength: 3,
templateSelection: formatProduct,
templateResult: formatProduct,
ajax: {
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
type: "POST",
url: '/ajaxGetProductsSelect2Search',
dataType: 'json',
delay: 250,
data: function (params) {
var query = {
search: params.term,
type: 'public'
};
return query;
},
processResults: function (data) {
var arr = []
$.each(data, function (index, value) {
arr.push({
id: value['tw_Nazwa'],
text: value['tw_Nazwa'],
symbol: value['tw_Symbol'],
})
})
return {
results: arr
};
}
},
},
style_class: 'form-control',
filter_reset_button_text: false,
}
function formatProduct(option) {
var symbol = option.symbol ? ' <strong>[' + option.symbol + ']' : '';
var $ob = $('<span value='+option.text+'>' + option.text + symbol + '</span>');
return $ob;
}
DataTables version: 1.13.8
Yadcf version: 0.9.4.beta.46
Any hints for how to get it working? Thanks.
jarrettj commented
Hey, good day.
Same issue :|.
Here it works:
https://yadcf-showcase.appspot.com/DOM_source_select2.html
Here it does not:
https://yadcf-showcase.appspot.com/DOM_Ajax_Multiple_1.10.html
In the older API it works in the example, but not the new one. Any help would be much appreciated :).
Regards,
Jarrett