{"action":"created","issue":{"url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/370","labels_url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/370/labels{/name}","comments_url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/370/comments","events_url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/370/events","html_url":"https://github.com/kartik-v/yii2-grid/issues/370","id":105532959,"number":370,"title":"refreshGrid only works once","user":{"login":"macbax","id":2436665,"avatar_url":"https://avatars.githubusercontent.com/u/2436665?v=3","gravatar_id":"","url":"https://api.github.com/users/macbax","html_url":"https://github.com/macbax","followers_url":"https://api.github.com/users/macbax/followers","following_url":"https://api.github.com/users/macbax/following{/other_user}","gists_url":"https://api.github.com/users/macbax/gists{/gist_id}","starred_url":"https://api.github.com/users/macbax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macbax/subscriptions","organizations_url":"https://api.github.com/users/macbax/orgs","repos_url":"https://api.github.com/users/macbax/repos","events_url":"https://api.github.com/users/macbax/events{/privacy}","received_events_url":"https://api.github.com/users/macbax/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-09T07:01:26Z","updated_at":"2015-09-29T08:22:01Z","closed_at":null,"body":"I set the refreshGrid to true, and the GridView will only refresh once after I updated data in the EditableColumn, I found some other user have the same problem, please fix if you have time. Tia."},"comment":{"url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/comments/143982620","html_url":"https://github.com/kartik-v/yii2-grid/issues/370#issuecomment-143982620","issue_url":"https://api.github.com/repos/kartik-v/yii2-grid/issues/370","id":143982620,"user":{"login":"Bhoft","id":1777147,"avatar_url":"https://avatars.githubusercontent.com/u/1777147?v=3","gravatar_id":"","url":"https://api.github.com/users/Bhoft","html_url":"https://github.com/Bhoft","followers_url":"https://api.github.com/users/Bhoft/followers","following_url":"https://api.github.com/users/Bhoft/following{/other_user}","gists_url":"https://api.github.com/users/Bhoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Bhoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bhoft/subscriptions","organizations_url":"https://api.github.com/users/Bhoft/orgs","repos_url":"https://api.github.com/users/Bhoft/repos","events_url":"https://api.github.com/users/Bhoft/events{/privacy}","received_events_url":"https://api.github.com/users/Bhoft/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T08:22:01Z","updated_at":"2015-09-29T08:22:01Z","body":"Hm i have tried this indexBy in the query, still the same issue.\r\nYou have written that in kvRefreshEC the grid id is used that is correct, but the 2nd parameter is the id of the Editable column. \r\nAnd this ID is changed each Pjax refresh of the grid (e.g. sorting, searching or refresh after an editable change).\r\n\r\nI have added 2 debug outputs to the Editablecolumn\r\n```\r\nto the init function\r\n $this->_view->registerJs(\"console.log(['init \\$this->_css', '{$this->_css}']);\");\r\nto the renderDataCellContent function\r\n$this->_view->registerJs(\"console.log(['renderDataCellContent \\$this->_css', '{$this->_css}']);\");\r\n```\r\n\r\ne.g. on a normal get request i have these 2 console logs\r\n```\r\n[\"init $this->_css\", \"kv-edcol-0e645061\"]\r\n[\"renderDataCellContent $this->_css\", \"kv-edcol-0e645061\"]\r\n```\r\n\r\nSo the init of the EditableColumn has added a js to the view like:\r\n```\r\nkvRefreshEC('grid_id','kv-edcol-0e645061')\r\n```\r\n\r\nIf I sort for any column of the grid the grid is refreshed normally via pjax.\r\nAnd i get only one console log with another css id which is used in the editable columns.\r\n```\r\n [\"renderDataCellContent $this->_css\", \"kv-edcol-81ade31b\"]\r\n```\r\nIf i then change an editable value the refreshGrid doesn't work because there is no js added to my page through that pjax request which uses the new editablecolumn id like: \r\n```\r\nkvRefreshEC('grid_id','kv-edcol-81ade31b')\r\n```\r\nIf you add a editable column to a pjax grid yourself and set the refreshgrid parameter to true you would see it yourself that the grid is only refreshed once if the editable change is done after the normal get request or not at all if the grid was refreshed with an pjax request.\r\nBecause on Pjax::begin() creates a new instance of the calling class. \r\nhttp://www.yiiframework.com/doc-2.0/yii-base-widget.html#begin%28%29-detail\r\n\r\nOr in other words everything between the Pjax::begin and Pjax::end is sent back on the request.\r\nBut the initColumns is done before (inside the Gridview::init()) so every js which is added in the init sections isn't sent to the browser on Pjax requests.\r\nSo the refresh doesn't work because the EditableColumn id is changed every request.\r\n\r\nIf the refresh js code is moved to the renderDataCellContent function it will work as expected.\r\n\r\n\r\n"}}