Skip to content

Instantly share code, notes, and snippets.

that._getData = function (navTermID, listName, xmlQuery, contentType, onGetSuccess) {
var objClientCtx = new SP.ClientContext.get_current(); //can be reused
if (objClientCtx) {
var oList = objClientCtx.get_web().get_lists().getByTitle(listName);
var query = new SP.CamlQuery();
query.set_viewXml(xmlQuery);
var objlistItems = oList.getItems(query);
objClientCtx.load(objlistItems);
objClientCtx.executeQueryAsync(function (sender, args) {
that.DataSet = [];
var oList = objClientCtx.get_web().get_lists().getByTitle(listName);
var query = new SP.CamlQuery();
query.set_viewXml(xmlQuery);
var objlistItems = oList.getItems(query);
objClientCtx.load(objlistItems);
objClientCtx.executeQueryAsync(
function (sender, args) {
that.DataSet = [];
var objlistEnumerator = objlistItems.getEnumerator();
while (objlistEnumerator.moveNext()) {
var objListItem = objlistEnumerator.get_current();
var firstName = objListItem.get_item('FirstName');
var lastName = objListItem.get_item('LastName');
var email = objListItem.get_item('Email');
that.DataSet.push({
"FirstName": firstName,
"LastName": lastName,
"Email": email,
});
[
{
"FirstName": "abc",
"LastName": "xyz",
"Email": "abc@xyz.com"
},
{"FirstName": "def",
"LastName": "mnq",
"Email": "def@mnq.com"
@premchandpl
premchandpl / CallSharePointListFunction.js
Created June 18, 2014 22:24
Call Share Point List Function
GetSharePointListData(spListName, camlQuery, function (data) {
$("#customerTemplate").tmpl(data).appendTo("#divCustomer");
});
@premchandpl
premchandpl / CustomJQueryTemplate.js
Last active August 29, 2015 14:02
Customer jQuery Template
<script id="customerTemplate" type="text/x-jquery-tmpl">
<li>
<a href="mailto:${Email}">${FirstName} ${LastName}</a>
</li>
</script>
<div id="divCustomer">
<ul id="ulCustomer">
</ul>
</div>
@premchandpl
premchandpl / CustomRTETableStyle.css
Created June 26, 2014 17:04
Custom Table RTE Styles
table.ms-rteTable-myCustomTable
{
-ms-name:"My Custom Table";
}
.ms-rteTable-myCustomTable > tbody > tr > td,
.ms-rteTable-myCustomTable > tbody > tr > th
{
border: 1px solid #C6C6C6;
@premchandpl
premchandpl / openInDialog
Created July 10, 2014 16:17
Opening the page in a dialog
openInDialog = function (dlgTitle, dlgWidth, dlgHeight, dlgAllowMaximize, dlgShowClose, needCallBackFunction, pageUrl, dialogData) {
var options = { title: dlgTitle, url: pageUrl, width: dlgWidth, height: dlgHeight, allowMaximize: dlgAllowMaximize, showClose: dlgShowClose, args: dialogData };
if (needCallBackFunction) {
options.dialogReturnValueCallback = Function.createDelegate(null, closeDialogCallBack);
}
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}