ctx
is a global variable. It belongs in the list view pages.
var ctx = SP.ClientContext.get_current();
So if you use above line in any list view pages, it will cause an issue. The value of ctx
will be overridden by SP.ClientContext.get_current();
. You will not get any info from ctx
after above line.
In SharePoint 2013, it works and widely using in CSR. It has more info than in 2010. Following things we can get from ctx
in SharePoint 2013
["listBaseType", "listTemplate", "listName", "view", "listUrlDir", "HttpPath", "HttpRoot", "serverUrl", "imagesPath", "PortalUrl", "RecycleBinEnabled",
"enteringGridMode", "inGridMode", "isWebEditorPreview", "rootFolderForDisplay", "isPortalTemplate", "isModerated", "recursiveView", "displayFormUrl",
"editFormUrl", "newFormUrl", "ctxId", "CurrentUserId", "isForceCheckout", "EnableMinorVersions", "ModerationStatus", "verEnabled", "isVersions",
"WorkflowsAssociated", "ExternalDataList", "HasRelatedCascadeLists", "CascadeDeleteWarningMessage", "ContentTypesEnabled", "SendToLocationName",
"SendToLocationUrl", "StateInitDone", "TotalListItems", "CurrentSelectedItems", "LastSelectableRowIdx", "SelectAllCbx", "TableCbxFocusHandler", "TableMouseoverHandler",
"onItemSelectionChangedHandlers", "wpq", "Templates", "ListData", "ListSchema", "BaseViewID", "ListTemplateType", "existingServerFilterHash", "noGroupCollapse",
"NavigateForFormsPages", "BasePermissions", "CurrentUserIsSiteAdmin", "IsAppWeb", "AllowGridMode", "rootFolder", "viewTitle", "NoScriptEnabled", "OfficialFileName",
"OfficialFileNames", "WriteSecurity", "SiteTitle", "ListTitle", "isXslView", "IsClientRendering", "RegionalSettingsTimeZoneBias", "CanShareLinkForNewDocument", "SiteTemplateId",
"bInitialRender", "ListDataJSONItemsKey", "ControlMode", "SiteClientTag", "CurrentLanguage", "CurrentCultureName", "CurrentUICultureName", "OnPreRender", "OnPostRender",
"canDragUpload", "RenderView", "RenderHeader", "RenderBody", "RenderFooter", "RenderGroups", "RenderItems", "RenderFields", "RenderFieldByName", "heroId", "CurrentItem",
"CurrentItemIdx", "CurrentFieldSchema", "fHidden", "clvp", "queryString"]
- Total number of properties of
ctx
in 2010 is 49
- Total number of properties of
ctx
in 2013 is 94
If you have multiple lists in a page, then you will have multiple ctx
.
I have two lists in a page. My ctx
's are ctx37
and ctx73
PS: Unfortunately, It is not documented by MSDN. The all we have for exploring it is: Browser's console.
var ctx
inside a function will create a locally scoped variable, not overriding ctx in the global scope.