yadcf filter never null

yadcf filter never null

mbencimbenci Posts: 11Questions: 6Answers: 0

After the default value in yadcf (thanks for the great work done) now I have the necessity to have a filter that can't be null.
Is it possible to force one filter to have obligatorily a value?

Thanks and regards,
Marco B

Answers

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    You mean that you want your filter to act as a required field? is it in a form? you can always add a required="true" to it using js, explain your scenario....

  • mbencimbenci Posts: 11Questions: 6Answers: 0

    SOme details;
    I'm using the server side configuration and the yadcf plugins as filter mechanism.
    I have some filter but one of these("year", the first one) can't be null otherwise the data shown have no sense.
    Yes it must be a required filter but in yadcf as a I can click on reset button a new query starts (with "year" null).
    Now the year filter has a dropdown menu with year values and "selected value" as options,
    I'd like that if there is not value on the year filter nothing has to happen or that the filter "years" can't be null,

    yadcf.init(oTable,[
        {column_number : 1, filter_container_id: "external_filter_container"},
        {column_number : 2, filter_container_id: "external_filter_container2"},
        {column_number : 4, filter_type: "range_number_slider",filter_delay: 500},
        {column_number : 5, filter_type: "range_number_slider",filter_delay: 500},
        {column_number : 6, filter_type: "range_number_slider",filter_delay: 500},
        {column_number : 7},
        {column_number : 8},
        {column_number : 9}
    ]);
    
            
    yadcf.exFilterColumn(oTable, [
         [1, year],
         [2, month],
         [9, region]
    ]);
    

    Thanks,
    Marco B

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    you can remove the reset button with filter_reset_button_text: false (boolean false)
    and you can remove the "select value" which reset the selection with a simple jquery command

    $('#yadcf-filter--example-0 option[value=\'-1\']').remove();
    

    (see what id your relevant select element has)

  • mbencimbenci Posts: 11Questions: 6Answers: 0

    Thank you very much,

    with these two configurations I obtain exactly what I want.

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    you are welcome.

This discussion has been closed.