SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This script works but only for one selected item

              var items = SP.ListOperation.Selection.getSelectedItems();
              (items.length == 1 && items[0].fsObjType == 0);"/>   

I need that the user can select many files or folder. If in the selection there is at least one folder, button should be disabled, if all items are just files, button should be enabled

share|improve this question
up vote 1 down vote accepted

I guess you can use something like this (not tested):

for (int i =0; i < items.length; i++)
   if (items[i].fsObjType == 1)
      return false;
return true;
share|improve this answer
items[0] would test always the first element of the list, isnt it? – Esteban V Mar 8 '12 at 10:03
Sorry it was a mistake :) I've updated. – Alex Boev Mar 8 '12 at 10:05
how can I escape the < character? – Esteban V Mar 8 '12 at 10:10
Error 10 Character '<', hexadecimal value 0x3c is illegal in XML attribute values. – Esteban V Mar 8 '12 at 10:11
cant find how to escape that :( – Esteban V Mar 8 '12 at 10:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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