@@ -17,7 +17,7 @@ soon...
1717
1818## Requirements
1919
20- PHP 5.4 or higher.
20+ PHP 5.6 or higher.
2121
2222## Installation
2323
@@ -49,12 +49,20 @@ Include jupitern/table in your project, by adding it to your composer.json file.
4949->setData($data)
5050
5151// add attributes to the <table > html tag one by one
52- ->attr('id', 'demoTable')
53- ->attr('class', 'table table-bordered table-striped table-hover')
54- ->attr('cellspacing', '0')
52+ ->attr('table', ' id', 'demoTable')
53+ ->attr('table', ' class', 'table table-bordered table-striped table-hover')
54+ ->attr('table', ' cellspacing', '0')
5555
5656// or add all <table > attributes at once
57- ->attrs(['class' => 'table table-bordered', 'cellspacing' => '0']);
57+ ->attrs('table', ['class' => 'table table-bordered', 'cellspacing' => '0'])
58+
59+ // add attributes to the table rows
60+ ->css('tr', 'background-color', 'red')
61+
62+ // add attributes to the table rows using a callable
63+ ->attr('tr', 'data-id', function($row) {
64+ return 'row-' . $row['id'];
65+ })
5866
5967// add a new column for array data
6068->column()
@@ -112,10 +120,10 @@ Include jupitern/table in your project, by adding it to your composer.json file.
112120->column()
113121 ->title('Name')
114122 ->value('name')
115- ->attr('data-val', 'foo', true ) // add attributes to <th >
116- ->css('background-color', '#f5f5f5', true ) // add css to <th >
117- ->attr('data-val', 'bar') // add attributes to <td >
118- ->css('background-color', '#f5f5f5') // add css to <td >
123+ ->attr('th', ' data-val', 'foo') // add attributes to <th >
124+ ->css('th', ' background-color', '#f5f5f5') // add css to <th >
125+ ->attr('td', ' data-val', 'bar') // add attributes to <td >
126+ ->css('td', ' background-color', '#f5f5f5') // add css to <td >
119127->add()
120128
121129// echo table output
@@ -140,38 +148,38 @@ $filterData = $db->query("SELECT name as val, name FROM persons limit 10")->fetc
140148
141149\Jupitern\Table\Table::instance()
142150 ->setData($data)
143- ->attr('id', 'demoTable')
144- ->attr('class', 'table table-bordered table-striped table-hover')
145- ->attr('cellspacing', '0')
146- ->attr('width', '100%')
151+ ->attr('table', ' id', 'demoTable')
152+ ->attr('table', ' class', 'table table-bordered table-striped table-hover')
153+ ->attr('table', ' cellspacing', '0')
154+ ->attr('table', ' width', '100%')
147155 ->column()
148156 ->title('Name')
149157 ->value(function ($row) {
150158 return rand(1,10)%2 ? '<b >'.$row->name.'</b >' : $row->name;
151159 })
152160 ->filter($filterData)
153- ->css('color', 'green')
154- ->css('width', '50%')
155- ->css('background-color', '#ccc', true)
161+ ->css('td', ' color', 'green')
162+ ->css('td', ' width', '50%')
163+ ->css('td', ' background-color', '#ccc', true)
156164 ->add()
157165 ->column()
158166 ->title('Age')
159167 ->value('age')
160168 ->filter()
161- ->css('color', 'red')
162- ->css('width', '20%')
169+ ->css('td', ' color', 'red')
170+ ->css('td', ' width', '20%')
163171 ->add()
164172 ->column('Phone')
165173 ->filter()
166174 ->value('phone')
167- ->css('color', 'red')
168- ->css('width', '20%')
175+ ->css('td', ' color', 'red')
176+ ->css('td', ' width', '20%')
169177 ->add()
170178 ->column()
171179 ->value(function ($row) {
172180 return '<a href =" country/'.$row->id.'" >edit</a >';
173181 })
174- ->css('width', '10%')
182+ ->css('td', ' width', '10%')
175183 ->add()
176184 ->render();
177185?>
0 commit comments