Created
June 9, 2017 01:14
-
-
Save davehax/63ec95de0be3637c3ef1c5fef1fc9733 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getSchemaDataForCurrentView() { | |
| var webPartKey = ''; | |
| var webPartComponent = null; | |
| var schemaData; | |
| // based on the current view id we can find our way to a WPQ<number>SchemaData variable which has the goodies we need to check in it! | |
| // First, get the web part component variable | |
| for (var key in _spWebPartComponents) { | |
| var a = _spWebPartComponents[key]; | |
| if (a.storageId && a.storageId == _spPageContextInfo.viewId.replace(/(\{|\})/g, '')) { | |
| webPartComponent = _spWebPartComponents[key]; | |
| webPartKey = key; | |
| break; | |
| } | |
| } | |
| // now if we found one we can search for the SchemaData variable | |
| if (webPartKey != '') { | |
| // get variable name we can search window for | |
| var partialKey = webPartKey.replace('WebPart', ''); | |
| var _schemaData = window[partialKey + 'SchemaData']; | |
| if (typeof(_schemaData) !== 'undefined') { | |
| schemaData = _schemaData; | |
| } | |
| } | |
| return schemaData; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment