Появилась задача, что бы сотрудники компании могли
распечатать заявки согласно определенной формы. При этом была возможность выбрать
сразу несколько и распечатать.
Как основное решение для формы печати было React приложение,
размещенное на страницу, а в представлении добавил кастомную кнопку на риббон которая
отрывала новый таб с требуемой страницей и передавала ID выделенных элементов
как параметр.
Что бы добавить кнопку нужно единожды выполнить код в консоли:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //Get the client context and list object var context = new SP .ClientContext.get_current(); var list = context.get_web().get_lists().getByTitle(_spPageContextInfo.listTitle); //Get the custom user action collection and add the user action var customUserAction = list.get_userCustomActions().add(); // Set the location of the user action customUserAction.set_location( 'CommandUI.Ribbon.ListView' ); //Add the properties for the custom action '<commanduidefinitions>' + '<commanduidefinition location="Ribbon.List.Actions.Controls._children">' + '<button abeltext="Распечатать заявки" emplatealias="o1" equence="0" escription="Print" id="Ribbon.Documents.New.RibbonTest" mage16by16="/Style%20Library/Images/printer.png" mage32by32="/Style%20Library/Images/printer.png" ommand="PrintRequest">' + '</button></commanduidefinition>' + '</commanduidefinitions>' + '<commanduihandlers>' + '<commanduihandler command="PrintRequest" nabledscript="javascript:SP.ListOperation.Selection.getSelectedItems().length > 0;" ommandaction="javascript:window.open(\'https:\/\/contoso.sharepoint.com\/SitePages\/CourierServicePrintPage.aspx?isdlg=1&selectedItems=\'+SP.ListOperation.Selection.getSelectedItems().map(function(item){ return item.id; }).join(\',\') ,\'_blank\'); ">' + '</commanduihandler></commanduihandlers>' + '</commanduiextension>' ; //Add the command UI extension and update the custom user action customUserAction.set_commandUIExtension(userActionExtension) customUserAction.set_title( "Распечатать заявки" ); customUserAction.update(); //Load the client context and execute the batch context.load(list, 'UserCustomActions' ); context.executeQueryAsync(function() { console.log( "Custom User Action added successfully to ribbon." ); }, function(sender, args) { console.log(args.get_message()); }); |
Комментариев нет:
Отправить комментарий