{"action":"created","issue":{"url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/259","labels_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/259/comments","events_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/259/events","html_url":"https://github.com/daniel-nagy/md-data-table/issues/259","id":127701879,"number":259,"title":"Problem witch display selected checkbox on next page","user":{"login":"pawelrm","id":16800109,"avatar_url":"https://avatars.githubusercontent.com/u/16800109?v=3","gravatar_id":"","url":"https://api.github.com/users/pawelrm","html_url":"https://github.com/pawelrm","followers_url":"https://api.github.com/users/pawelrm/followers","following_url":"https://api.github.com/users/pawelrm/following{/other_user}","gists_url":"https://api.github.com/users/pawelrm/gists{/gist_id}","starred_url":"https://api.github.com/users/pawelrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pawelrm/subscriptions","organizations_url":"https://api.github.com/users/pawelrm/orgs","repos_url":"https://api.github.com/users/pawelrm/repos","events_url":"https://api.github.com/users/pawelrm/events{/privacy}","received_events_url":"https://api.github.com/users/pawelrm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-20T15:06:23Z","updated_at":"2016-01-20T16:08:37Z","closed_at":null,"body":"I use md-data-table on Angular Material mdDialog window. I have problem witch display selected checkbox on page different than first. When I reopen window and change page, selected checkbox are not checked until I check one off them.\r\n\r\nMy code:\r\n\r\n```html\r\n<md-table-container ng-if=\"this.viewModel.userList\">\r\n    \t<table md-table md-row-select data-ng-model=\"viewModel.selected\" md-progress=\"viewModel.promise\">\r\n\t        <thead md-head>\r\n\t            <tr md-row>\r\n\t                <th md-column data-md-order-by=\"name\"><span>Id</span></th>\r\n\t                <th md-column data-md-order-by=\"fullName\"><span>Name</span></th>\r\n\t                <th md-column data-md-order-by=\"email\"><span>Mailable</span></th>\r\n\t            </tr>\r\n\t        </thead>\r\n\t        <tbody md-body>\r\n\t            <tr md-row md-select=\"user\" md-select-id=\"{{user.userId}}\" md-auto-select md-on-select=\"searchUser.log()\" ng-repeat=\"user in viewModel.userList | filter: filter.search | orderBy: messCtrl.query.order | limitTo: viewModel.limit : (viewModel.page -1) * viewModel.limit\">\r\n\t                <td md-cell>{{user.name}}</td>\r\n\t                <td md-cell>{{user.fullName}}</td>\r\n\t                <td md-cell>{{user.email}}</td>\r\n\t            </tr>\r\n\t        </tbody>\r\n\t    </table>\r\n\t</md-table-container>\r\n```\r\n\r\nI had some problem with rechecking selected checkbox on reopen window and that it's a reason, why I again add selected elements to variable \"selected\":\r\n\r\n```javascript\r\nconstructor(...) {\r\n            ...\r\n            this.mdDialog = $mdDialog;\r\n            this.viewModel.limit = 5;\r\n            this.viewModel.page = 1;\r\n            this.viewModel.selected = [];\r\n\r\n            this.getUsers(selected);\r\n        }\r\n\r\n        public getUsers(selected: User[]): void {\r\n            this.viewModel.promise = this.communicationService.browseUsers().then((response: User[]): void => {\r\n                if (response.length > 0) {\r\n                    this.viewModel.userList = response;\r\n                    var added;\r\n                    for(var i = 0; i < selected.length; i++) {\r\n                        added = _.find(this.viewModel.userList, function(num : User) { return num.userId == selected[i].userId});\r\n                        this.viewModel.selected.push(added);\r\n                    }\r\n                }\r\n            });\r\n        }\r\n````"},"comment":{"url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/comments/173252137","html_url":"https://github.com/daniel-nagy/md-data-table/issues/259#issuecomment-173252137","issue_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/259","id":173252137,"user":{"login":"daniel-nagy","id":1622446,"avatar_url":"https://avatars.githubusercontent.com/u/1622446?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-nagy","html_url":"https://github.com/daniel-nagy","followers_url":"https://api.github.com/users/daniel-nagy/followers","following_url":"https://api.github.com/users/daniel-nagy/following{/other_user}","gists_url":"https://api.github.com/users/daniel-nagy/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-nagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-nagy/subscriptions","organizations_url":"https://api.github.com/users/daniel-nagy/orgs","repos_url":"https://api.github.com/users/daniel-nagy/repos","events_url":"https://api.github.com/users/daniel-nagy/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-nagy/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T16:08:37Z","updated_at":"2016-01-20T16:08:37Z","body":"Your table is inside a dialog? The dialog is going to get a new isolated scope every time it is opened. You'll want to keep your selected items outside the dialog and pass them to it when you open the dialog.\r\n\r\n```javascript\r\nvar selected = [];\r\n\r\n$mdDialog.show({\r\n  ...\r\n  locals: {\r\n    selected: selected\r\n  },\r\n  ...\r\n});\r\n ```"}}