we're customizing a lot of customers sharepoint sites and we need to turn on/off QuickEdit multiple times, I want to create a Bookmarklet to achieve this, but the setting can't be found.
I've tried by changing the SchemaXML of the list, but it doesn't do anything.. Thanks for any advice!
var context = SP.ClientContext.get_current();
var web = context.get_web();
var listTitle = 'MyList';
var list = web.get_lists().getByTitle(listTitle);
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('" + listTitle + "')";
var xmlDoc;
// Load the schema XML for the list
context.load(list, 'SchemaXml');
context.executeQueryAsync(function() {
var schemaXml = list.get_schemaXml();
// Convert schema XML string to XML DOM object
var parser = new DOMParser();
xmlDoc = parser.parseFromString(schemaXml, 'text/xml');
// Get the List node
var listNode = xmlDoc.getElementsByTagName('List')[0];
// Add or update the EnableGridEditing attribute to the List node
listNode.setAttribute('DisableGridEditing', 'FALSE');
var newSchemaXml = xmlDoc.documentElement.outerHTML;
console.log(newSchemaXml);
var postBody = JSON.stringify({ '__metadata': { 'type': 'SP.List' }, 'SchemaXml': newSchemaXml });
$.ajax({
url: url,
type: "POST",
data: postBody,
headers: {
"X-HTTP-Method":"MERGE",
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*"
},
success: function () {
console.log("List schema updated successfully");
},
error: function (err) {
console.log(err.responseText);
}
});
}, function(sender, args) {
console.log(args.get_message());
});