Static text for server side column presentation
Static text for server side column presentation
mconstable
Posts: 4Questions: 1Answers: 0
I want the return data to include a column with some static content (like "/" below) and even though this works I get a warning in my php-errors.log with "PHP Notice: Undefined index: in /path/to/server-side.php" so I suspect I am doing this incorrectly. Would anyone have a suggestion how to provide some static content per column?
$columns = [
['dt' => 0, 'db' => 'domain'],
['dt' => 1, 'db' => 'num_aliases'],
['dt' => 2, formatter' => function($d) { return '/'; } ],
['dt' => 3, 'db' => 'aliases'],
This discussion has been closed.
Answers
Currently the demo SSP script doesn't have that ability. It will always lookup a database column for each entry in the array. If you want it to not do that, you'd need to modify the script.
Allan
Heh, oh boy, that's going to be fun. I was hoping I wouldn't have to touch the SSP class.
Somewhat related, in the example above, is there a way to pass in the tables primary key "id" without requiring it as a rendered table column yet still have access to it as $row['id'] ?
FWIW I think I have this working by putting some exceptions in the SSP class methods including being able to add an "invisible" column if dt=null so that, in this example, $row['id'] is available inside the anon formatter function.
Yes, just don't define a column in the Javascript / HTML that uses it. It will still be in the JSON data, but not displayed.
Allan
Doh, thanks for that. I see an example somewhere of ['db' => 'id'] but now that I've added some logic to detect the ['db' => 'id', 'dt' => null] case I get an error if I remove my 'dt' => null. One thing that might be useful in general is that I managed to get column order sort working by using this in ::order($request, $columns)...
instead of the original...