How fetch a Cell value from a column in TableView javafx?

后端 未结 1 1810
北荒
北荒 2021-01-01 08:13

I am working on a basic billing application, totally new to javafx. Am done with adding and deleting the products from the table and also finding out the

相关标签:
1条回答
  • 2021-01-01 08:31

    You don't get the data from the cell, you get it from the model:

    double totalCostOfSelectedItems = 0 ;
    for (Data product : productSelected) {
        totalCostOfSelectedItems = totalCostOfSelectedItems + product.getRTotal();
    }
    finalCost = finalCost - totalCostOfSelectedItems() ;
    
    allProducts.removeAll(productSelected);
    

    And of course you could always just recompute the total after removal instead, which would only be a performance issue if you had a huge number of products in the table:

    allProducts.removeAll(productSelected) ;
    finalCost = allProducts.stream().collect(Collectors.summingDouble(Data::getRTotal));
    // update label...
    
    0 讨论(0)
提交回复
热议问题