Skip to content
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

GridView JS problem with custom template #2516

Closed
buakos opened this issue May 29, 2013 · 4 comments
Closed

GridView JS problem with custom template #2516

buakos opened this issue May 29, 2013 · 4 comments
Assignees
Milestone

Comments

@buakos
Copy link
Contributor

buakos commented May 29, 2013

The fix for #769 and #1225 seems to be somewhat incomplete.

There are (at least) 4 more places to replace children with find:

  1. selectCheckedRows
  2. the event handler for .select-on-check-all click
  3. getRow
  4. getColumn

I think there is no more place, but essentially everywhere settings.tableClass is the selector the code should search also in deeper levels.

Without these changes the check-all box and the other functions do not work correctly with a custom template like this:
<div class="items-wrapper">{items}</div>

@mdomba
Copy link
Member

mdomba commented May 29, 2013

Please give more details as what does not work for you... also provide the complete grid code.

I just set on one a grid 'template' => '<div class="items-wrapper">{items}</div>',

and the "check all" works as expected... also selecting all rows checks the checkboxes of those rows and the "check all" box.

@buakos
Copy link
Contributor Author

buakos commented May 29, 2013

You can try eg. this one:

$rawData = array(
  array('name' => 'Name1', 'value' => 'Value1'),
  array('name' => 'Name2', 'value' => 'Value2'),
  array('name' => 'Name3', 'value' => 'Value3'),
);
$dataProvider = new CArrayDataProvider($rawData, array(
  'keyField' => false,
  ));
$template = '<div class="items-wrapper">{items}</div>';

$this->widget('zii.widgets.grid.CGridView', array(
  'id' => 'test-grid',
  'dataProvider' => $dataProvider,
  'selectableRows' => 2,
  'template' => $template,
  'columns' => array(
    array(
      'class' => 'CCheckBoxColumn',
    ),
    'name',
    'value',
  ),
)); 

As you can see, checking the box does not select any rows (only checks the boxes without adding the selected class). Also the getRow and getColumn methods return incorrect results.

buakos added a commit to buakos/yii that referenced this issue May 29, 2013
@mdomba
Copy link
Member

mdomba commented May 31, 2013

right, issue confirmed...

I was clicking directly on the row and then it was working, the check-all click is not working...

Request a PR and we will merge the changes...

@buakos
Copy link
Contributor Author

buakos commented Jun 1, 2013

OK, thanks!

@ghost ghost assigned mdomba Jun 1, 2013
@mdomba mdomba closed this as completed in 60b7f28 Jun 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants