2

My requirement is that i have created a custom ribbon control and i want to enable it for specific document library.

Can anyone please guide me for that?

Thanks,

2

Yes i think you can do that:
After you created your Action Button(or ribbon control), in "Elements.xml" of your control you need to add "EnabledScript" command to it, like this:

  <CustomAction Id="Shakib.EditPermissionForce" Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Permission.Modify.Controls._children">
          <Button
              Id="Ribbon.Permission.Modify.PermissionButton"
              Sequence="50"
              Command="ActionPermissionCommand"
              Image32by32="/_layouts/Shakib/images/perm32.png"
              Image16by16="/_layouts/Shakib/images/perm16.png"
              LabelText="Some Label"
              TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ActionPermissionCommand"
                          EnabledScript="javascript:EnableDoAction();"
                          CommandAction="javascript:DoAction();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>  

In "EnabledScript" command you need to specify a logical method which return Boolean, like this:

function EnableDoAction() {
    var ids = GetIds();
    return (ids.length > 0);
}  

In this method you can use all of the SharePoint client object models and verify that if this is the Document library you want.
I think its better to use an external JavaScript file. you can add a reference link to Action Element file("Elements.xml") like this:

  <CustomAction
    ScriptSrc="/_layouts/Shakib/dialog.js"
    Location="ScriptLink"
    Sequence="100">
  </CustomAction>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.