Comments (6)
So, I think I found what I was doing wrong but I'm not sure this is correct still.
I have set up the parseExtensions version (which, sound be Router::extensions I realized after trial and error) from the README. My controller has:
public $components = [
'RequestHandler' => [
'viewClassMap' => ['csv' => 'CsvView.Csv']
]
];
and my function is:
public function staff()
{
$this->paginate = [
'contain' => ['Users', 'Conventions']
];
$query = $this->People->find();
$query->where(['role !=' => 6]);
$this->set('people', $this->paginate($query));
$this->set('_serialize', ['people']);
$this->set('_extract', ['id', 'name', 'convention.name']);
}
This works! It feels like _extract should be ['Person.id', 'Person.name', 'Convention.name'], which is what the readme shows and what had messed me up before.
from cakephp-csvview.
When you use models with relations, you're expected to use the _serialize
option to pull out the data you want.
I didn't want to "automatically" pull out the data, since it gets pretty weird when you start getting into multiple levels of relationships, and probably best handled by the user with the aforementioned option.
Does that explanation help?
from cakephp-csvview.
Somewhat, although I don't see how to pull out data with _serialize, I'd played a bit with _extract but didn't seem to get the correct result either. Would you be kind enough as to provide an example?
from cakephp-csvview.
oh sorry yeah, _extract
. Basically It's the same syntax as Hash::get()
, so anything that works there works here.
Do you have an example entity/relation set that you can provide and the _extract
code you used? We can help set you straight if we know what you're dealing with.
from cakephp-csvview.
Ah! Okay, the readme is definitely a bit wrong, and is using the array conventions from 2.x instead of the toArray
output in 3.x. Can you file a PR against the readme, updating it to remove the extra table prefix, and normalizing the capitalization?
from cakephp-csvview.
Sure!
from cakephp-csvview.
Related Issues (20)
- BOM appears in all rows if _bom is enabled HOT 1
- Safary issue with generated CSV HOT 2
- How to generate specific list(drop down list) in CVS? HOT 1
- csvView save only html code HOT 7
- Missing template in export HOT 2
- Example of a complex csv view file HOT 2
- Got encoding issue with arabic characters HOT 5
- accessing fields with enableAutoFields HOT 1
- Extending the CsvView class and RequestHandler HOT 2
- support for cakephp 4 HOT 2
- Export data from query with related table HOT 4
- How can I output a UTF-8 CSV that Excel will read properly? HOT 1
- Missing Template
- cakephp 4 version is not working as expected HOT 1
- Plugin CsvView could not be found (cake 3.9) HOT 1
- Deprecation warning with CakePHP 4.3 HOT 1
- filename extension doesn't work in chrome browser HOT 1
- CSV export in cake 3.6 HOT 5
- Outputting large amounts of rows HOT 1
- unable to unit test for downloads HOT 6
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 cakephp-csvview.