Problem with yadcf
Problem with yadcf
Hello,
I'm trying to make a filter.
But when i try it I can't change the values of the selectboxes.
Full code:
var firstTable;
var url
$.ajax({
url:"php/sessiontest.php",
success:function(data){
if (data==""){
url='./php/ajax.php';
}else{
url='./php/ajax.php?filter=' + data;
};
},
async:false
});
firstTable = $('#data').DataTable({"aaSorting":[[3,"desc"]],"responsive":true,"pagingType": "full_numbers","aLengthMenu": [[10, 20, 30, 50, 75, 100, -1], [10, 20, 30, 50, 75, 100, "Alle"]],"iDisplayLength":30, stateSave:true, scrollY:"85%", "language":{"url":"scripts/German.lang"}, "dom": '<"top"f>rt<"bottom"ip><"clear">', "processing": true, "ajax":{'url':url,'dataType':'json','type':'POST'}, "aoColumns":[{"data":"Problem","title":"Problem"},{"data":"Ansprechpartner",className:"never"},{"data":"Ort","title":"Ort"},{"data":"Erstelldatum","title":"Erstelldatum"},{"data":"Status","title":"Status"},{"data":"geloest", className:"never"},{"data":"Bearbeiter", className:"never"},{"data":"Abteilung", className:"never"},{"data":"Bearbeiterabteilung", className:"never"},{"data":"ID", className:"never"}]
});
yadcf.init(firstTable,[
{column_number : 1, filter_type:'select', select_type:'chosen', select_type_options: {disable_search: false}, filter_container_id:"external_ansprechpartner_filter", filter_default_label:"Wählen Sie einen Ansprechpartner", filter_reset_button_text:false},
{column_number : 2, text_data_delimiter: ",",filter_type:"text"},
{column_number : 5, filter_type:'select', select_type:'chosen', select_type_options: {disable_search: true}, filter_container_id:"external_anzeige_filter", data:[{value:'1',label:'Nur gelöste Anzeigen'},{value:'0',label:'Nur ungelöste Anzeigen'}], filter_default_label:"Alle Anzeigen", filter_reset_button_text:false},
{column_number : 6, filter_type:'select', select_type:'chosen', select_type_options: {disable_search: false}, filter_container_id:"external_bearbeiter_filter", filter_default_label:"Wählen Sie einen Bearbeiter", filter_reset_button_text:false},
{column_number : 7, filter_type:'select', select_type:'chosen', select_type_options: {disable_search: false}, filter_container_id:"external_abteilung_filter", filter_default_label:"Wählen Sie eine Abteilung", filter_reset_button_text:false},
{column_number : 8}
]);
$(window).resize(function () {
firstTable.columns.adjust();
});
yadcf.exFilterColumn(firstTable,[[5,"0"]]);
$.post("php/sessiontest.php",function(data){
if (data==""){
if ($("#yadcf-filter--data-7").val()==-1 && $("#yadcf-filter--data-1").val()==-1){
yadcf.exFilterColumn(firstTable,[[1,"-1"], [7,"-1"]]);
}
$("#yadcf-filter--data-1").change(function(){
yadcf.exResetFilters(firstTable, [1,7]);
if ($("#yadcf-filter--data-7").val()==-1 && $("#yadcf-filter--data-1").val()==-1){
yadcf.exFilterColumn(firstTable,[[1,"-1"], [7,"-1"]]);
}
});
$("#yadcf-filter--data-7").change(function(){
yadcf.exResetFilters(firstTable, [1,7]);
if ($("#yadcf-filter--data-7").val()==-1 && $("#yadcf-filter--data-1").val()==-1){
yadcf.exFilterColumn(firstTable,[[1,"-1"], [7,"-1"]]);
}
});
$("#yadcf-filter--data-7 option:first").attr("disabled","disabled");
$("#yadcf-filter--data-1 option:first").attr("disabled","disabled");
}else{
yadcf.doFilter('clear', '-data', 7);
yadcf.doFilter('clear', '-data', 1);
}
});
The Problem is the $.post part.
Here should if somebody is not logged in and 1 and 7 stay on the filter_default_label no data should be displayed.
If somebody selects 1, 7 should be resetet and vice versa.
The filter_default_label should not be selectable.
I also use the choosen plugin
Answers
I suggest you to simplify your problem to a simplier scenario of your issue and then post a jsbin/jsfiddle sample that reproduces your problem, because I can't understand which part of yadcf does not work as expected
https://jsfiddle.net/emLfa5s0/6/
If both filters are not set I want no data to be visible.
Only on filter can be set at the same time.
On set one filter the other should be reset.
My example shows it without ajax but it makes similar problems
https://jsfiddle.net/Markus92/emLfa5s0/9/
Sorry, new link
plz go over the code and fix all typos and wrong ids / more?
yadcf-filter--data-0 / otTable / firstTable
I'm sorry, here is a version I think everything is ok.
https://jsfiddle.net/emLfa5s0/10/
I hope you unterstand my Problem
think so, its just i'm lacking of time to take a deeper look at it atm, will see what can be done