-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating test case and a few fixes #9
Conversation
@@ -144,7 +134,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) | |||
$this->_search($object); | |||
$this->_paginate($object); | |||
$results = parent::paginate($object, $scope, $whitelist); | |||
$totalDisplayed = $this->request->params['paging'][$object->alias]['count']; | |||
$totalDisplayed = $this->Controller->request->params['paging'][$object->alias]['count']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have a request object within the DataTableComponent - unless this is to say its unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the extra param is necessary; especially being public.
But this change is actually a mistake thinking about it now. I should be calling initialize()
in the test. I'll update the test and revert this. Your call if you think a request property should be available. If you do, I'd recommend making it protected.
Actually don't merge this yet. I'll write some more extensive tests later and update this pull. |
I came across an interesting issue with using the paginator component. When the EDIT: Yes pointless to do limit => 5... but still an issue if adding conditions in an action. |
For component branch or master, or both? edit: I can't reproduce |
I fixed the App::uses and removed constructor along with other stuff in my last commit. |
Also, the reason for extending PaginatorComponent was to keep both functionality? To do normal paginating and js paginating? If that's the case then I need to modify paginate() method a bit. |
Only with the component branch. Pushing the progress I have so far... |
I hope it merges without problems. I think we do need the constructor, so we can merge DataTableCompoennt::settings with PaginatorComponent::settings, then merge user passed settings - or copy/paste PaginatorComponent::settings default to DataTableComponent. |
I can't reproduce it and there's a debug statement in your commit. I have public function index() {
$this->paginate = array('limit' => 5);
} but DataTableComponent::settings looks fine. It gets merged, not overwritten. Edit: well not really, it doesnt even get merged because of if (isset($this->Controller->paginate[$object->alias])) { If it was $this->paginate['Model'] = array(....); it would merge. How can I set it up to reproduce the error? |
Sorry just coding and thinking out loud. To reproduce do:
The reason is This is just a problem for those who want to use DataTable and normal Paginator on the same controller (CakePackages has this). Although... maybe I was wrong and you are right about extending paginator... diving into it; maybe it's more trouble then it's worth? (Please dont kill me :) |
Still can't reproduce it but to accomplish what you want DataTableComponent::paginate needs to be changed to something like: function paginte(...) {
if (!$this->isdDataTableRequest()) {
return parent::paginate(....);
}
.... rest of datatable for jquery stuff ...
} or move have separate methods for them. I'm done for the day though. |
I still can't reproduce. Running that code just outputs json for me since it sets the view class to DataTableResponseView but no errors and settings are all there. I can't see how it would get overwritten. Calling Controller::paginate() just passes Controller::$paginate to the Component which merges only. Are you sure its not something specific to your app? Check the comments I left in the code. |
parent::__construct($collection, array_merge($this->settings, $settings)); | ||
public function __construct(ComponentCollection $Collection, $settings = array()) { | ||
parent::__construct($Collection, $settings); | ||
$this->_settings = $this->settings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So _settings and settings are identical now. See comment below
I used a fresh clone of CakePHP 2.1. Cloned the DataTable component branch to app/Plugin/DataTable. Then in the PagesController added an index action with the code mentioned above (removed the default route to PagesController:display() as well). Then I get this error message:
ROOT2plugins = /var/www/cake2plugins/ btw... cake is mistakenly screwing that up in error messages (on my list things to fix in cake ;) It is because this line in the core Controller: https://github.com/cakephp/cakephp/blob/master/lib/Cake/Controller/Controller.php#L430 Doing Setting I didn't know the Paginator component was this tied to Controllers until now. Otherwise I wouldn't have thought this would be a good idea. Your method on master is superior, imho. |
Ah! I set I like extending the Paginator because it fixes the 2.1 fields issue too without any messy unsetting and then merging and it has a better _getObject() method to get the model. I'm almost done with the helper, I'll add the fix for the component in a bit. |
And there's another boog. In beforeRender() when it sets the view var, |
Awesome man! Just let me know if/when your ready for me to write some tests. :) |
Actually, I'm not going to fix that. Two simpler solutions are a) don't alias Paginator (see note below) or b) add I think I'm going to keep DataTableComponent (while still extending PaginatorComponent) only for jquery server-side. If you need normal paginating include PaginatorComponent and use each accordingly. |
Helper done. see temporary wiki https://github.com/tigrang/cakephp-datatable/wiki/Helper |
No description provided.