Add New Column dynamically on CRUD Table New Column addition dynamically on CRUD Table

You can add new table column dynamically based on two columns value for example you want to show order total based on order sub total and tax. You can also merge two columns to generate a new column for example you can merge first name and last name to generate new column "Full Name". By default, new column is added at the last. Since it is dynamic column, so it doesn't support search/sort/export function.

  
                                 $pdocrud = new PDOCrud();
                                    //Add new column total which is calculated as sum of two columns (you can pass any no. of columns)
                                    $pdocrud->tableColAddition("Total", "sum",array("product_sell_price","tax"));
                                     //Add new colum Profit which is calculated as subtraction of two columns
                                    $pdocrud->tableColAddition("Profit", "subtract",array("product_price","product_sell_price"));
                                    //Add new colum Sell/price which is calculated as division of two columns
                                    $pdocrud->tableColAddition("Sell/price", "divide",array("product_sell_price","product_price"));
                                    //Merge column to generate a new column ( you can pass any no. of columns)
                                    $pdocrud->tableColAddition("Product Info", "merge",array("product_id","product_name"));
                                    $pdocrud->crudTableCol(array("product_name","product_id", "product_price","product_sell_price","tax","product_discount"));
                                    $pdocrud->crudRemoveCol(array("product_name","product_id"));
                                    echo $pdocrud->dbTable("products")->render();
                            

Add new table column

Products

Showing 1 to 10 of 110 entries

# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions
1 0.00 0.00 0 0 0 123213
2 48.81 95.70 0 5 95.7 46.89 0.51003134796238 4671.117 S10_1678 1969 Harley Davidson Ultimate Chopper
3 50.00 214.30 0 0 214.3 164.3 0.23331777881475 10715 S10_1949 1952 Alpine Renault 1300
4 68.99 118.94 0 0 118.94 49.95 0.58004035648226 8205.6706 S10_2016 1996 Moto Guzzi 1100i
5 91.02 193.66 0 0 193.66 102.64 0.46999896726221 17626.9332 S10_4698 2003 Harley-Davidson Eagle Drag Bike
6 85.68 136.00 0 0 136 50.32 0.63 11652.48 S10_4757 1972 Alfa Romeo GTA
7 103.42 147.74 0 0 147.74 44.32 0.70001353729525 15279.2708 S10_4962 1962 LanciaA Delta 16V
8 95.59 207.80 0 0 207.8 112.21 0.46000962463908 19863.602 S12_1108 2001 Ferrari Enzo
9 77.90 136.67 0 0 136.67 58.77 0.56998609790005 10646.593 S12_1666 1958 Setra Bus
10 66.27 150.62 0 0 150.62 84.35 0.43998141017129 9981.5874 S12_2823 2002 Suzuki XREO
# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions