Comments (3)
Happy Lunar New Year.
In the TableIgniter, setOutput()
allows you to transmit arrays consists of the strings and anonymous function. If the array includings anonymous function, you should be aware of these three hints down below:
- TableIgniter will process every data fetched from the database on by one, and every time it will process the anonymous function you transferred.
- The anonymous function must only have a single parameter, and the parameter should be according to the database. This means you can do the logical judgments you need and the preprocessing for each row of data
- The
return
of the anonymous function must be aString
, because the TableIgniter will combine the results into the frontend DataTables.
I made some changes to the codes you provided:
public function fetchProjectData()
{
$table = new TablesIgniter();
$table->setTable($this->projectModel->noticeTable())
->setDefaultOrder('project_name', 'ASC')
->setOrder([
'project_name', 'client_name', 'pm_name',
'start_date', 'finish_date', 'project_status', null
])
->setSearch(['project_name', 'client_name', 'pm_name', 'project_status'])
->setOutput([
'project_name', 'client_name', 'pm_name', 'start_date',
'finish_date', $this->projectStatus(), $this->projectModel->button()
]);
return $table->getDatatable();
}
public function projectStatus()
{
$closureFun = function ($row) {
// $row should belong to the query results.
if ($row['project_status'] == 'hold') {
return '<span class="badge rounded-pill bg-primary">Hold</span>';
} else {
return '<button type="button" class="btn btn-info">Detail</button>';
}
}
return $closureFun;
}
from tablesigniter.
Issue solved. Thank you!
I will close this thread.
from tablesigniter.
Hi
public function projectStatus()
{
$closureFun = function ($row) {
// $row should belong to the query results.
if ($row['status'] == '1')
{
return 'Hold';
} else {
return 'Detail';
}
}
return $closureFun;
}
getting syntax error, unexpected token "return"
Thanks
from tablesigniter.
Related Issues (11)
- Wanna ask HOT 1
- class not found HOT 24
- throws exception HOT 1
- CI 3 HOT 4
- Undefined index: draw HOT 3
- Not working with Searchpanes - Not supported? HOT 3
- Model builder HOT 1
- Problems with Search HOT 5
- Problems with PHP 8
- how to implement column search HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tablesigniter.