diff --git a/README.md b/README.md index 34c5c97..83b518e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ It's similar to Microsoft's WebForms with a great layout by default (like DevExp ## Available components * Table * Card -* Breadcumb +* Breadcrumb ## Examples @@ -22,11 +22,29 @@ $table->setDataSource($employees); $table->setCustomCaptions(array("Name", "Surname", "Date of Birth", "Social Security Number")); //not required. If not specified it'll use objects' property names +$table->addColumn("Extra"); + +$table->onValueDisplaying("onValueDisplaying"); + $table->setStripedRows(true); $table->setBordered(true); $table->setHoverAnimation(true); $table->draw(); + +function onValueDisplaying($caption, &$value, $row){ + if($caption == "ssn"){ + if($row["ssn"] != "12345"){ + $value = "SSN not shown for privacy reasons"; + } + else{ + $value = $row["name"] . " " . $row["surname"] . " agreed to share their ssn (12345)" ; + } + } + else if($caption == "Extra"){ + $value = "This column did not exist in the datasource"; + } +} ``` produces the following output diff --git a/phpxpress/examples/demoTable.jpg b/phpxpress/examples/demoTable.jpg index c70fbb4..23c1b15 100644 Binary files a/phpxpress/examples/demoTable.jpg and b/phpxpress/examples/demoTable.jpg differ diff --git a/phpxpress/examples/table.php b/phpxpress/examples/table.php index 9b32c0c..85af30b 100644 --- a/phpxpress/examples/table.php +++ b/phpxpress/examples/table.php @@ -37,17 +37,28 @@ $table = new Table; $table->setDataSource($employees); $table->setCustomCaptions(array("Name", "Surname", "Date of Birth", "Social Security Number")); + + $table->addColumn("Extra"); + + $table->onValueDisplaying("onValueDisplaying"); + $table->setStripedRows(true); $table->setBordered(true); $table->setHoverAnimation(true); - $table->onValueDisplaying("onValueDisplaying"); // event - $table->draw(); - function onValueDisplaying($caption, &$value){ + function onValueDisplaying($caption, &$value, $row){ if($caption == "ssn"){ - $value = "SSN not shown for privacy reasons"; + if($row["ssn"] != "12345"){ + $value = "SSN not shown for privacy reasons"; + } + else{ + $value = $row["name"] . " " . $row["surname"] . " agreed to share their ssn (12345)" ; + } + } + else if($caption == "Extra"){ + $value = "This column did not exist in the datasource"; } } diff --git a/phpxpress/phpxpress/table.php b/phpxpress/phpxpress/table.php index 91fb0d9..9521836 100644 --- a/phpxpress/phpxpress/table.php +++ b/phpxpress/phpxpress/table.php @@ -46,7 +46,7 @@ foreach ($obj as $name => $value) { if(isset( $this -> onValueDisplayingFunctionName)){ - call_user_func_array($this -> onValueDisplayingFunctionName , array($name, &$value)); + call_user_func_array($this -> onValueDisplayingFunctionName , array($name, &$value, (array)$obj)); } echo '