-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
ExpandRowColumn- expandRowKey or expandRowInd is not set to $model->id #884
Comments
I would like to see this implemented. We need more data given from the call. |
This works as intended. Cross check the grid demo where it is been updated to include a |
On probably another related issue, in case you have updated jquery versions, I will push an update for jquery version >= |
Have incorporated enhancement to replace |
A rowID that is passed in the POST is worthless to me. I need something like the model's ID. I dont know what data is on row 5, for example. And plus, what happens after sorting and filtering? I need to do something like |
That is the model primary key which is passed in expandRowKey... Not sure what your issue is. You can cross check the demo on how each row fetches the data specific to the model. |
I know how you fetch the data in the demo but my table and DB structure is completely different. Your demos a very simple and include only 1 table with minimal information. The RowID given to me is 5, which corresponds to the row that I expanded. The PK for that row is not 5, but instead an internal ID such as 2837282. Why would a row in a table correspond to a PK in a table? I have grids that are very complex with many tables joined and many columns. RowID 5 tells me nothing about what row is expanded. I need to be able to access |
Read the issue from the original author of this bug:
If the grid youre showing has primary keys in the 7,000s, POSTing |
Again it is not the row id which you are stating but the primary key value (typically So if you folks are getting an incorrect If you need to index by the primary key - then use the With regards to enhancing to accept Closure for |
I dont even have a |
Yes and that is where the problem is as I was stating - if your data source has a primaryKey value defined it will be used by default and if you have a different non-standard data structure (not supported by default yii2 ActiveRecord) - then you would need to write your code appropriately. For example, you may need to override the |
I'm using ActiveDataProvider, but it is a union and complex
|
lol |
thanks, my code is based on ActiveDataProvider. indexBy solved problem. add this case to docs please |
I tried to override the |
Yes as I mentioned. Using |
Kartik has mentioned a few time here and there that you can set the key used by the dataProvider to whichever attribute/column you want. This will be what is put in the expandRowKey during the action. I do need the ability to create the url and pass other information though. Example: My row of data is a summed value. The expanded row is the detailed rows that go into that summed result. I need access to the $model attributes to pass them into the ajax call so I can create a proper database query to get the specific rows that went into the result. I am able to access $searchModel variable so that is great, but the row has specific attributes I need to pass to the detailed view like the fact that the sum is of only "cash" payments. //This is what I have done in order to get more specific information into the detailed view. It would be better to be able to load this data through a url though. |
I've been having same problem as well, however I think I've found a temporary solution.
What you can do is set "key" value in ActiveDataProvider object as a callable array, then in "ExpandRowKey" you get an array. That solves some problems. |
I don't know if this will serve my needs but this is SUPER powerful and one of the reasons I love Yii. Definitely kind of a hack but this allows some pretty cool functionality now. Will take a look. Thanks! |
Prerequisites
master
branch of yii2-grid.Steps to reproduce the issue
$columns[] = [ 'class' => 'kartik\grid\ExpandRowColumn', 'width' => '50px', 'value' => function ($model, $key, $index, $column){ Yii::error(__METHOD__. ": debug expand - ". print_r($model, true)); return GridView::ROW_COLLAPSED; }, 'detailUrl' => Url::to(['authors-expand']), 'expandOneOnly' => true, 'disabled' => function ($model, $key, $index, $column){ return $model->authors ? false : true; }, ];
log : `
common\models\Author Object
(
[_id:common\models\Author:private] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 7157
[id_user] => 30025
[id_detail] => 1
[created_at] => 2019-03-14 11:55:38
[updated_at] => 2019-03-14 11:55:38
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 7157
[id_user] => 30025
[id_detail] => 1
[created_at] => 2019-03-14 11:55:38
[updated_at] => 2019-03-14 11:55:38
)
........
`
Expected behavior and actual behavior
When I follow those steps, I see...
request body raw =
'expandRowKey=0&expandRowInd=0'
I was expecting...
expandRowInd=7157
Environment
Browsers
Operating System
Libraries
Isolating the problem
The text was updated successfully, but these errors were encountered: