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 108 entries

# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions
1 50.00 214.30 0 0 214.3 164.3 0.23331777881475 10715 S10_1949 1952 Alpine Renault 1300
2 91.02 193.66 0 0 193.66 102.64 0.46999896726221 17626.9332 S10_4698 2003 Harley-Davidson Eagle Drag Bike
3 85.68 136.00 0 0 136 50.32 0.63 11652.48 S10_4757 1972 Alfa Romeo GTA
4 103.42 147.74 0 0 147.74 44.32 0.70001353729525 15279.2708 S10_4962 1962 LanciaA Delta 16V
5 95.34 194.57 0 0 194.57 99.23 0.49000359767693 18550.3038 S12_1099 1968 Ford Mustang
6 95.59 207.80 0 0 207.8 112.21 0.46000962463908 19863.602 S12_1108 2001 Ferrari Enzo
7 77.90 136.67 0 0 136.67 58.77 0.56998609790005 10646.593 S12_1666 1958 Setra Bus
8 66.27 150.62 0 0 150.62 84.35 0.43998141017129 9981.5874 S12_2823 2002 Suzuki XREO
9 89.14 151.08 0 0 151.08 61.94 0.59001853322743 13467.2712 S12_3148 1969 Corvair Monza
10 75.16 117.44 0 0 117.44 42.28 0.6399863760218 8826.7904 S12_3380 1968 Dodge Charger
# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions