Disable sorting classes on specific columns

Disable sorting classes on specific columns

WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
edited July 2012 in General
I have a column with predefined background colors which must remain visible when it's sorted. Is this possible?

As a hack I was letting css simply ignore the first column, but the ":not" pseudo-class isn't supported in IE8.
[code].dataTables_wrapper tr.even td:not(:first-child).sorting_1[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can't disable the column sorting classes without just disabling sorting on the column, which I presume you don't want to do - but I suspect you are just running into a CSS selector priority issue - try assigning !important to the ones you want to keep.

    Allan
  • WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
    That's what I'm using now, but it breaks the ability to highlight the entire row with the same color.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you link us to the page - I'm sure that it will just need a CSS priority adjustment. Firebug will tell you what is overriding the styles.

    Allan
  • WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
    Sure thing.
    https://beta.propertypreswizard.com/test_scripts/beta/home.php

    This css is loaded first from wo_status.css (1st column td color):
    [code].wo_status__invoiced {
    background-color: #074BA7 !important;
    color: #FFFFFF !important;
    } [/code]

    Then from datatables.css (sorted column):
    [code].dataTables_wrapper tr.even td.sorting_1, .dataTables_wrapper tr.even td.sorting_2, .dataTables_wrapper tr.even td.sorting_3 {
    background-color: #E4E4E4;
    }

    /*.dataTables_wrapper tr.odd td:not(:first-child).sorting_1, .dataTables_wrapper tr.odd td.sorting_2, .dataTables_wrapper tr.odd td.sorting_3 {*/
    .dataTables_wrapper tr.odd td.sorting_1, .dataTables_wrapper tr.odd td.sorting_2, .dataTables_wrapper tr.odd td.sorting_3 {
    background-color: #f7f7f7;
    }[/code]

    Then when you highlight:
    [code].dataTables_wrapper tr:hover td{
    background-color: #d4e3fc;
    color: #000;
    }[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you not just modify the last code block there to be:

    [code]
    .dataTables_wrapper tr:hover td{
    background-color: #d4e3fc !important;
    color: #000;
    }
    [/code]

    You might need to increase the priority of your first code block as well:

    [code]
    .dataTables_wrapper tr td.wo_status__invoiced {
    background-color: #074BA7 !important;
    color: #FFFFFF !important;
    }
    [/code]

    Allan
This discussion has been closed.