I would like to add a custom action in the group "Connect and export" of the list ribbon when on the AllItems.aspx page. No server code is allowed. This should be done by using JavaScript. The picture shows where the new custom button should be added.
By now, I succeed to add the button to another group. Unfortunetely it is added every time I refresh the page. You can find the source here.
$(document).ready(function (){
ExecuteOrDelayUntilScriptLoaded(AddExportXlsCustomButton,"sp.js");
});
function AddExportXlsCustomButton(){
var context = new SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle("Dossiers CRME");
var customAction = list.get_userCustomActions().add();
customAction.set_location('CommandUI.Ribbon.ListView');
var uiExtension = '<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">' +
'<CommandUIDefinitions>' +
'<CommandUIDefinition Location="Ribbon.List.CustomizeList.Controls._children">'+
'<Button Id="Ribbon.Documents.New.RibbonCustomExcelExport" '+
'Command="Notify" '+
'Sequence="0" '+
'Image16by16="/_layouts/1036/images/formatmap16x16.png" '+
'Image32by32="/_layouts/1036/images/formatmap32x32.png" '+
'Description="Exporte les éléments sélectionnés vers un fichier Excel." '+
'LabelText="Exporter vers Excel (Personnalisé)" '+
'TemplateAlias="o1"/>' +
'</CommandUIDefinition>'+
'</CommandUIDefinitions>'+
'<CommandUIHandlers>'+
'<CommandUIHandler Command="Notify" '+
'CommandAction="javascript: ;" />'+
'</CommandUIHandlers>'+
'</CommandUIExtension>';
customAction.set_commandUIExtension(uiExtension);
customAction.update();
context.load(list,'UserCustomActions');
context.executeQueryAsync(Function.createDelegate(this, success),Function.createDelegate(this, error));
}
function success(){ console.log("success"); }
function error(){ alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }
Thank you very much.