{"action":"created","issue":{"url":"https://api.github.com/repos/SitePen/dgrid/issues/1106","labels_url":"https://api.github.com/repos/SitePen/dgrid/issues/1106/labels{/name}","comments_url":"https://api.github.com/repos/SitePen/dgrid/issues/1106/comments","events_url":"https://api.github.com/repos/SitePen/dgrid/issues/1106/events","html_url":"https://github.com/SitePen/dgrid/issues/1106","id":63602970,"number":1106,"title":"How to migrate 0.3 dgrid event.results passed by dgrid-refresh-complete?","user":{"login":"twelveeighty","id":8210823,"avatar_url":"https://avatars.githubusercontent.com/u/8210823?v=3","gravatar_id":"","url":"https://api.github.com/users/twelveeighty","html_url":"https://github.com/twelveeighty","followers_url":"https://api.github.com/users/twelveeighty/followers","following_url":"https://api.github.com/users/twelveeighty/following{/other_user}","gists_url":"https://api.github.com/users/twelveeighty/gists{/gist_id}","starred_url":"https://api.github.com/users/twelveeighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twelveeighty/subscriptions","organizations_url":"https://api.github.com/users/twelveeighty/orgs","repos_url":"https://api.github.com/users/twelveeighty/repos","events_url":"https://api.github.com/users/twelveeighty/events{/privacy}","received_events_url":"https://api.github.com/users/twelveeighty/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-23T02:09:16Z","updated_at":"2015-03-24T16:08:47Z","closed_at":null,"body":"In the 0.3 days of dgrid, a dgrid-refresh-complete event had a 'results' property with the latest data on the grid. We relied on this property to run post-processing against the results (totals, etc.) with having to re-query the storage back-end. In version 0.4, this 'results' property has been removed.\r\n\r\nWhat would be the \"new\" way of post-processing results returned from a Rest dstore upon dgrid-refresh-complete? In our case, the dgrid is hooked directly to the Rest dstore because I want to have sorting handled by the rest server. I also don't want to query the rest server twice, once for the grid and once more for post-processing.\r\n\r\nEdit: how about if the method set(\"collection\", some_collection) returns the promise from refresh() that gets called by set(\"collection\")? \r\n"},"comment":{"url":"https://api.github.com/repos/SitePen/dgrid/issues/comments/85582098","html_url":"https://github.com/SitePen/dgrid/issues/1106#issuecomment-85582098","issue_url":"https://api.github.com/repos/SitePen/dgrid/issues/1106","id":85582098,"user":{"login":"twelveeighty","id":8210823,"avatar_url":"https://avatars.githubusercontent.com/u/8210823?v=3","gravatar_id":"","url":"https://api.github.com/users/twelveeighty","html_url":"https://github.com/twelveeighty","followers_url":"https://api.github.com/users/twelveeighty/followers","following_url":"https://api.github.com/users/twelveeighty/following{/other_user}","gists_url":"https://api.github.com/users/twelveeighty/gists{/gist_id}","starred_url":"https://api.github.com/users/twelveeighty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twelveeighty/subscriptions","organizations_url":"https://api.github.com/users/twelveeighty/orgs","repos_url":"https://api.github.com/users/twelveeighty/repos","events_url":"https://api.github.com/users/twelveeighty/events{/privacy}","received_events_url":"https://api.github.com/users/twelveeighty/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T16:08:47Z","updated_at":"2015-03-24T16:08:47Z","body":"I'm all for alternatives if that's a better design! Here's what we were using the event.results property for: we query a rest server for a sales order type dataset. This dataset returns a low number of rows, less than 20. On the UI side, we have a page that shows the sales order dataset in a dgrid. In the v0.3 days, when the grid is populated using set(\"store\"), we calculate the total of the sales order using the event.results returned as part of the dgrid-refresh-complete event. This was very efficient, since the rest server is only queried once for a given sales order.\r\nWe need sorting of the dataset to be handled by the rest backend, which is exactly what dgrid is doing if we set the rest store/collection directly on the grid.\r\n\r\nIn essence, we are using the set(\"collection\") in the same way as refresh() would work, but I don't want to call refresh() again since set(\"collection\") has already pulled all the data I need. That's why I suggested to make set(\"collection\") return a promise just refresh() does?\r\n\r\nI'm open to suggestions. Currently, as a work-around, I have extended OnDemandGrid as follows:\r\n\r\n```javascript\r\nvar CachedOnDemandGrid = declare([ OnDemandGrid ], {\r\n\t_cachedResults: null,\r\n\trenderQueryResults: function(results, beforeNode, options) {\r\n\t\tthis._cachedResults = results;\r\n\t\treturn this.inherited(arguments);\r\n\t},\r\n\t_getCachedResults: function() {\r\n\t\treturn this._cachedResults;\r\n\t},\r\n});\r\n[...]\r\nvar MyGrid = declare([ CachedOnDemandGrid, ... ]);\r\nvar grid = new MyGrid({ ... });\r\nvar store = new Rest({\r\n\tidProperty: 'someId',\r\n\tsortParam: \"orderBy\",\r\n\ttarget: '/some/url/'\r\n});\r\ngrid.set(\"collection\", store.filter({someId: 3}));\r\ngrid.on(\"dgrid-refresh-complete\", function(event) {\r\n\tvar results = event.grid.get(\"cachedResults\");\r\n\tresults.forEach(function(entry) {\r\n\t\t...\r\n\t});\t\r\n});\r\n\r\n```\r\n\r\nThis works, but it's a bit of a hack, since I'm relying on renderQueryResults() being called somewhere deep inside the set(\"collection\") calls.\r\n"}}