how to Enable Custom Button On ribbon when select multiple list items

how to Enable Custom Button On ribbon when select multiple list items

I have a custom list and I have created a cutom action in View Ribbon which starts a workflow for the list item. When I select single list item thourgh checkbox it gets enabled. But When I select more than one items it gets disabled. I have to make it enabled for multiple items and I need it to start that workflow for all items selected. Please suggest posible work around.

Check following code for enable custom ribbon button when select multiple items

<CommandUIHandler Command="TaskCommand"
            CommandAction="javascript:alert('Not implemented.');"
            EnabledScript="javascript:enableButton();">
        </CommandUIHandler>

function enableButton() {
    var result = false;//default return value of the function which disables the button
    var selectedItems = SP.ListOperation.Selection.getSelectedItems();
    //check if more then one item is selected
    if (CountDictionary(selectedItems) > 1) {
      result = true;   
 }
    return result;
}

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright