Okay
  Public Ticket #2925597
Hide a separate Columns based on cell contents
Closed

Comments

  • Make Freedom started the conversation

    Hi. We have clients statuses we need to be able to see and update. For ease of use depending on the client filing type we want to only see certain columns in the results.

    This is not an issue affecting the other records in the table as the result for the page will only show one record that is picked on a previous page and passed to the page with the example below.

    https//oursite.com/client-editor/?wdt_column_filter[0]=005564

    In attachment 1 you can see that we are testing to see if the value of the cell matches a value type and setting a CSS for a column based on the result. We added a css class to the css shee on the back end of the plugin.

    We are not sure if this is the proper method, and most likely we do not have the css correct for the column. The name of the column we are trying to hide is:  Notaries_Sent

    Please help, we would appreciate your assistance greatly.

  •  472
    Isidora replied

    Hi Make,

    Thank you for your purchase.

    Sorry for the late response, we have some agents that have contracted Covid-19, so our team is cut in half.

    With conditional formatting you can do different actions available in condition that will be applied for that column only. This condition that you are using is created to be applied on all cells in that column. It is not created for case that you can hide hole column(with proper CSS you will hide only cells in table, column header will be visible)

    .wpDataTableID-1 .yourClassName{
        display:none !important;
    }

    Where 1 in .wpDataTableID-1 is id of the table and you will replace it with your id, and yourClassName you will replace with class that you insert in conditionn. This CSS you will insert in Custom CSS on Customize tab in table settings.

    After this you will see that all cells for this column are hidden and table header is still there and table is messup.

    To fix this you can try to add this in file wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js and around line 1658 you will find this

    case 'addColumnClass':

    and after that you will add this

    var classArr = $cell.attr("class").split(/\s+/);
    jQuery.each(classArr, function (key, value) {
        if (value.indexOf("column-") === 0) {
            $cell
                .closest('table.wpDataTable')
                .find('thead tr th.' + value)
                .addClass(setVal);
        }
    });

    so your code will look like this

    2333019545.png

    When you make those changes you will need to turn off option Minify JS on CUSTOM JS AND CSS in  settings of plugin.

    We will need to test this solution more to cover all cases before adding in core of plugin.

    Best regards.


    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables

  • Make Freedom replied

    Hi.

    This method is viable if we break our structure for management into many parts. The issue we are running into is that if we do not make the column visible it does not affect the row... We do not want the same column listed on 11 tables, we simple want to use the hidden column to affect the row css as you have helped with.

  • Make Freedom replied

    We hid the left the column visible in the setting and just hid it with css using this method. That way it affected the other columns but is not unsightly.

    table.wpDataTable thead tr th.column-newcolumn, table.wpDataTable tbody tr td.column-newcolumn{
    display:none !important;
    }

    This method can be found here for others ease of use:
    https://wpdatatables.com/faqmd/use-conditional-formatting-hidden-columns/


  • Make Freedom replied

    This should really be easier...

    If you added another column in the conditional formatting as to which column or row it was affecting then we could add a whole new dynamic to our use case scenarios. 

  • [deleted] replied

    Hi Make

    Thank you for the update, and I do agree there is room for improvement when it comes to conditional formatting.

    I'll kindly ask you to add it as a feature suggestion on this page. 

    Features are pushed up on our "to-do" list when there are a lot of customers requesting those features, so having your vote as a customer can be beneficial to this feature being developed sooner.

    Do let us know if there is anything else we can assist you with.

    Have a wonderful daysmile.png