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::ROW_EXPANDED doesn't work #947

Closed
5 tasks done
pappfer opened this issue Feb 12, 2020 · 12 comments
Closed
5 tasks done

GridView::ROW_EXPANDED doesn't work #947

pappfer opened this issue Feb 12, 2020 · 12 comments

Comments

@pappfer
Copy link
Contributor

pappfer commented Feb 12, 2020

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of yii2-grid.
  • This is not an usage question. I confirm having gone through and read the documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.

This bug is similar to #586 what I fixed earlier.
I have this setting:

'value' => function ($model, $key, $index, $column) {
    if (Yii::$app->request->get('id') == $key) {
        return kartik\grid\GridView::ROW_EXPANDED;
    } else {
        return kartik\grid\GridView::ROW_COLLAPSED;
    }
},

Even thought the id parameter is passed, the row won't open.
The problem is caused by line 228-230 in kv-grid-expand.js:

if (isExpanded($icon)) {
    return;
}

It occurs because isExpanded will be true when GridView::ROW_EXPANDED is set, so it ignores the rest of the javascript code and won't open the row.
I currently don't have the chance to check why those lines are present so I can't create a pull request at the moment.

@kartik-v
Copy link
Owner

Thanks - the row expansion on INIT was intended to work by default with plain CSS (so no JS was needed to parse) - but if you are using ajax based rendering option for expanded detail (instead of normal render) it may not work. Will need to check this.

@pappfer
Copy link
Contributor Author

pappfer commented Feb 12, 2020

Yes, I'm using ajax based rendering.

@kartik-v
Copy link
Owner

This has been resolved with the latest commit (also has a related enhancement #948).

@pappfer
Copy link
Contributor Author

pappfer commented Feb 12, 2020

@kartik-v Sorry, but doesn't seem to work. It is complaining about an undefined variable at line 192.
TypeError: $detail.html(...) is undefined

@kartik-v
Copy link
Owner

@pappfer - I am not able to reproduce your issue - hope you have the latest assets loaded?

How are you configuring your ExpandRowColumn (are you using nested GridViews)?

kartik-v added a commit that referenced this issue Feb 12, 2020
@kartik-v
Copy link
Owner

kartik-v commented Feb 12, 2020

I pushed in a commit. Can you retry and let know?

@pappfer
Copy link
Contributor Author

pappfer commented Feb 12, 2020

I don't get the console error now, but the row doesn't get expanded. I am not using nested GridViews.
I am using a configuration mentioned in the first post along with 'detailUrl'.

@kartik-v
Copy link
Owner

kartik-v commented Feb 13, 2020

I am unable to reproduce your issue. Currently to show this works fine - there is a new ExpandRowColumn demo enabled on the demos page. Refer the new expand row column demo. You can cross check the grid columns configuration by clicking the Grid Columns Setup button.

This has similar configuration with detailUrl to render via ajax and selective rows expanded on INIT (in the example demo even numbered rows are configured to be expanded on init).

Let me know if you have something else on your environment or configuration which is missed.

@pappfer
Copy link
Contributor Author

pappfer commented Feb 14, 2020

It is really weird, because in my project sometimes it works, sometimes it doesn't. Sure, I am using the latest version and having the cache and the web/assets folder cleared.
Unfortunately I don't have time to debug it now, for now I am using version 3.3.4 in my Composer and it works fine with that. When I'll get a little time, I'll investigate the issue.

@cebe
Copy link
Contributor

cebe commented May 26, 2020

@kartik-v I'm having the same issue, not sure about the cause but I think this should be reopened. I'll try to figure out more details about this tomorrow.

@hoaaah
Copy link

hoaaah commented Aug 16, 2020

Got this issue too, but after clean my assets folder, it works again.

@cebe
Copy link
Contributor

cebe commented Aug 17, 2020

In our case it was conflicting with custom JS code of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants