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

# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions
1 95.59 207.80 0 0 207.8 112.21 0.46000962463908 19863.602 S12_1108 2001 Ferrari Enzo
2 77.90 136.67 0 0 136.67 58.77 0.56998609790005 10646.593 S12_1666 1958 Setra Bus
3 89.14 151.08 0 0 151.08 61.94 0.59001853322743 13467.2712 S12_3148 1969 Corvair Monza
4 75.16 117.44 0 0 117.44 42.28 0.6399863760218 8826.7904 S12_3380 1968 Dodge Charger
5 83.05 173.02 0 0 173.02 89.97 0.48000231187146 14369.311 S12_3891 1969 Ford Falcon
6 31.92 79.80 0 0 79.8 47.88 0.4 2547.216 S12_3990 1970 Plymouth Hemi Cuda
7 55.70 118.50 0 0 118.5 62.8 0.47004219409283 6600.45 S12_4473 1957 Chevy Pickup
8 58.73 115.16 0 0 115.16 56.43 0.50998610628691 6763.3468 S12_4675 1969 Dodge Charger
9 58.33 116.67 0 0 116.67 58.34 0.4999571440816 6805.3611 S18_1097 1940 Ford Pickup Truck
10 83.51 141.54 0 0 141.54 58.03 0.59000989119683 11820.0054 S18_1129 1993 Mazda RX-7
# Product price Product sell price Tax Product discount Total Profit Sell/price Random Product Info Actions