Friday 15 June 2012

javascript - Apply class to parent row, if child cell contains a specific value -


problem

If a value appears in its hair cells, then I want to hide one row.

desired effect
  • Apply the square to the row, if one of its hair cells has a specific value
  • Bonus Challenge: The column containing the value Hide, i.e. "Admin-hide"

    example code
      $ ('tr'). Each (function () (if ($ ('td: contains (non-member'), this). {$ (This) .addClass ('disabled');}});   

    Why?

    The invaluable tables which require information:

    • Toggle on / off without losing back-end data, i.e. member roster, With missing member rows of the display: None;
    • Highlights of special lines, i.e. premium sponsors

      I have encountered difficulties

      Column Hidden If necessary, I can touch just hidden rows with the child.

      I'm working Tech
      • Wordpress 3.5.1
      • Jazzery 1.10.1
      • Taskpress plugging (which uses the Datatylls plugin for junkery)

        attempt # 1

        In this page I have the editor in WordPress:

          [table id = 3 /] & lt; script & gt; jQuery (function ($) {$ ('# tableID tr') Filter (function () {$ ('Td', this) .each (function () {if ($ (this) .t Ext () IndexOf ('admin-hide')! = -1) $ ('# tableID tr td: eq (' + $ (this). Index () + ')'). Wrap (); }); Refund $ (this) .text (). IndexOf ('non-member')! = -1; }) AddClass ('Disabled'). }); & Lt; / Script & gt; & Lt; Style & gt; . Displayed {display: none;} & lt; / Style & gt;   

        attempt # 2 - @ adino

        hides this row, but breaks the datatable / tablepress:

          & lt ; Script & gt; AddClass ('disabled-cell') var index = $ ('td: ("admin-hide") is included ("admin-hide")'). Index (); $ ('Th, td', '# tablespace-3'). Filter ('nth-child (' + (Index + 1) + ')'). AddClass ('disabled cells');}); & Lt; / Script & gt; & Lt; Style & gt; .disable-cells {display: none;} & lt; / Style & gt;   

        Effort # 3 - @ Spencer J.

        This hides the row, which allows for data, however, this column does not hide.

          & lt; Script & gt; Jquery (function ($) {$ ('# tablepress-3 td). Each (function () {if ($ (this) .text (). IndexOf (' admin-hide ')! == -1) / Table formatting $ (this). CSS ('visibility', 'hidden');}}) // Hide entire row $ '(' # Table -3 tr: includes: 'admin-hide') ' ); Hide ();}); & lt; / script & gt;    

          jQuery (function ($) {$ Table = $ ('# tablepress-3'); $ ('th, td', $ table) .each (function () {if ( $ (This) .text (). IndexOf ('Admin only')! == -1) {var indices = $ (this). Index (); $ ('th: eq (' + index + '), td : Eq ('+ index +') ',' tr ', $ tab ) .hide ();}}) // Hide the entire row $ ('tr: in it ("subscription expired"), $ table) .hide ();});    

No comments:

Post a Comment