javafx - Hide Cells in a tableview using CSS when columns are integers -


i have tableview 1 of columns is:

private tablecolumn<userdata, integer> countlistcolumn; 

i have been able empty cells vanish using css in columns except one, shows 0 in each cell. i've tried following:

.table-row-cell:empty {     -fx-background-color: transparent; } .table-row-cell:empty {     -fx-border-width: 0px; } .table-row-cell:null {     -fx-background-color: transparent; } .table-row-cell:null {     -fx-border-width: 0px; } .list-cell:empty {     -fx-background-color: white; } .list-cell:empty {     visibility:hidden; } 

none of these seem work, nor binding. there way hide these cells or make them respond css? below i've tried.

     public class guicontroller implements subscriptionobserverif {       @fxml     private observablelist<list> list = fxcollections.observablearraylist();     @fxml     private tableview<data> table;     @fxml     private tablecolumn<data, integer> column;     @fxml     private tablecolumn<data, string> column2;      @fxml     private void initialize() throws exception {          table.setplaceholder(new label(" select column information"));         datatable.setcolumnresizepolicy(tableview.constrained_resize_policy);         //table1.setstyle("-fx-table-cell-border-color: transparent;");         table.setcolumnresizepolicy(tableview.constrained_resize_policy);         //table.setfixedcellsize(50);         //table.prefheightproperty().bind(bindings.size(datatable.getitems()));         //table.prefheight(datatable.getitems().size());         // column.getstyleclass().add("style_tableview.css");           column.setcellvaluefactory(data -> data.getvalue().columnproperty().asobject());         column2.setcellvaluefactory(data -> data.getvalue().columnproperty().asstring());          column2.setcellfactory(factory -> new tablecell<data, string>() {             @override             protected void updateitem(string item, boolean empty) {                 super.updateitem(item, empty);                  if (empty) {                     //system.out.println("empty");                     //item = null;                     //setstyle("-fx-border-width: 0px;");                 }else if (!empty){                     system.out.println("column2 not empty");                     system.out.println(item);                     if(integer.parseint(item) == 0){                         system.out.println("definitely zero");                         setstyle("-fx-border-width: 0px;");                         setstyle("-fx-background-color: transparent;");                     }else{                         system.out.println("column2 not empty , not zero");                         getstyleclass().clear();                         //getstyleclass().addall("darktheme.css");                         setstyle("-fx-background-color: navy;");                         setstyle("-fx-border-width: 1000px;");                         //setstyle(null);                         column2.setcellvaluefactory(data -> data.getvalue().columnproperty().asstring());                      }                 }              }         }); //        column.setcellfactory(factory -> new tablecell<data, integer>() { //            @override //            protected void updateitem(integer item, boolean empty) { //                super.updateitem(item, empty); //                if(item instanceof integer) { //                        settext(integer.tostring((integer) item)); //                        settext(null); //                } //                if (empty) { //                    settext(null); //                } else if (item == 0) { //                    settext(null); //                } else { //                    settext(item.tostring()); //                } //            } //        });         statuscolumn.setcellvaluefactory(celldata -> celldata.getvalue().statusproperty());         timelinecolumn.setcellvaluefactory(celldata -> celldata.getvalue().dataproperty());          //intstream.range(0, 20).maptoobj(integer::tostring).foreach(datatable.getitems()::add);  // //        datatable.setfixedcellsize(25); //        datatable.prefheightproperty().bind(datatable.fixedcellsizeproperty().multiply(bindings.size(datatable.getitems()).add(1.01))); //        datatable.minheightproperty().bind(datatable.prefheightproperty()); //        datatable.maxheightproperty().bind(datatable.prefheightproperty());         timelinecolumn.setcellfactory(column -> {             return new tablecell<data, observablelist<datadata>>() {                 @override                 protected void updateitem(observablelist<data> item, boolean empty) {                     super.updateitem(item, empty);                      if(empty) {                         setgraphic(null);                      }                     else {                         this.autosize();                         setgraphic(datagraphic.creategraphic(item, datatable.getheight(), datatable.getwidth(), position));); //                      datatable.setstyle("-fx-table-cell-border-color: white;"); //                      datatable.setfixedcellsize(25); //                      datatable.prefheightproperty().bind(datatable.fixedcellsizeproperty().multiply(bindings.size(datatable.getitems())));                     }                };         });                    } 

i think sollution problem:

countlistcolumn.setcellfactory(factory -> new tablecell<userdata, integer>() {         @override         protected void updateitem(integer item, boolean empty) {             super.updateitem(item, empty);             if (empty) {                 settext(null);             } else if (item == 0) {                 settext(null);             } else {                 settext(item.tostring());             }         }     }); 

and of course have set cellvaluefactory way:

    countlistcolumn.setcellvaluefactory(data -> data.getvalue().countproperty().asobject()); 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -