[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorSortTableExample extends PhabricatorUIExample { 4 5 public function getName() { 6 return 'Sortable Tables'; 7 } 8 9 public function getDescription() { 10 return 'Using sortable tables.'; 11 } 12 13 public function renderExample() { 14 15 $rows = array( 16 array( 17 'make' => 'Honda', 18 'model' => 'Civic', 19 'year' => 2004, 20 'price' => 3199, 21 'color' => 'Blue', 22 ), 23 array( 24 'make' => 'Ford', 25 'model' => 'Focus', 26 'year' => 2001, 27 'price' => 2549, 28 'color' => 'Red', 29 ), 30 array( 31 'make' => 'Toyota', 32 'model' => 'Camry', 33 'year' => 2009, 34 'price' => 4299, 35 'color' => 'Black', 36 ), 37 array( 38 'make' => 'NASA', 39 'model' => 'Shuttle', 40 'year' => 1998, 41 'price' => 1000000000, 42 'color' => 'White', 43 ), 44 ); 45 46 $request = $this->getRequest(); 47 48 $orders = array( 49 'make', 50 'model', 51 'year', 52 'price', 53 ); 54 55 $sort = $request->getStr('sort'); 56 list($sort, $reverse) = AphrontTableView::parseSort($sort); 57 if (!in_array($sort, $orders)) { 58 $sort = 'make'; 59 } 60 61 $rows = isort($rows, $sort); 62 if ($reverse) { 63 $rows = array_reverse($rows); 64 } 65 66 $table = new AphrontTableView($rows); 67 $table->setHeaders( 68 array( 69 'Make', 70 'Model', 71 'Year', 72 'Price', 73 'Color', 74 )); 75 $table->setColumnClasses( 76 array( 77 '', 78 'wide', 79 'n', 80 'n', 81 '', 82 )); 83 $table->makeSortable( 84 $request->getRequestURI(), 85 'sort', 86 $sort, 87 $reverse, 88 $orders); 89 90 $panel = new PHUIObjectBoxView(); 91 $panel->setHeaderText('Sortable Table of Vehicles'); 92 $panel->appendChild($table); 93 94 return $panel; 95 } 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |