{"action":"opened","issue":{"url":"https://api.github.com/repos/skybrud/Skybrud.Umbraco.GridData/issues/21","repository_url":"https://api.github.com/repos/skybrud/Skybrud.Umbraco.GridData","labels_url":"https://api.github.com/repos/skybrud/Skybrud.Umbraco.GridData/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/skybrud/Skybrud.Umbraco.GridData/issues/21/comments","events_url":"https://api.github.com/repos/skybrud/Skybrud.Umbraco.GridData/issues/21/events","html_url":"https://github.com/skybrud/Skybrud.Umbraco.GridData/issues/21","id":240569126,"number":21,"title":"Allow parsing single GridControl from JObject","user":{"login":"ronaldbarendse","id":1051287,"avatar_url":"https://avatars1.githubusercontent.com/u/1051287?v=3","gravatar_id":"","url":"https://api.github.com/users/ronaldbarendse","html_url":"https://github.com/ronaldbarendse","followers_url":"https://api.github.com/users/ronaldbarendse/followers","following_url":"https://api.github.com/users/ronaldbarendse/following{/other_user}","gists_url":"https://api.github.com/users/ronaldbarendse/gists{/gist_id}","starred_url":"https://api.github.com/users/ronaldbarendse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronaldbarendse/subscriptions","organizations_url":"https://api.github.com/users/ronaldbarendse/orgs","repos_url":"https://api.github.com/users/ronaldbarendse/repos","events_url":"https://api.github.com/users/ronaldbarendse/events{/privacy}","received_events_url":"https://api.github.com/users/ronaldbarendse/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-05T08:01:47Z","updated_at":"2017-07-05T08:01:47Z","closed_at":null,"body":"For backend preview rendering (using a custom grid control or LeBlender for example), only the JSON for the control itself is provided as model. I've not found an easy solution to parse a single control to the data models, because it requires a section, that requires a row, that requires an area, etc.\r\n\r\nFor now, I've used the following workaround to render a single grid control (`\\Views\\Partials\\Grid\\Editors\\Base.cshtml`):\r\n\r\n```C#\r\n@model JObject\r\n@using Newtonsoft.Json.Linq;\r\n@using Skybrud.Umbraco.GridData\r\n@{\r\n    Layout = null;\r\n\r\n    // Workaround to get a parsed grid control\r\n    var grid = GridDataModel.GetEmptyModel();\r\n    var control = GridControl.Parse(GridArea.Parse(GridRow.Parse(GridSection.Parse(grid, new JObject()), new JObject()), new JObject()), Model);\r\n\r\n    // Use editor alias as partial view\r\n    var view = Model.GetValue(\"editor\").Value<string>(\"alias\");\r\n}\r\n@control.GetHtml(Html, view)\r\n```"}}
{"actor":{"display_login":"ronaldbarendse"}}