none
PWA Ribbon: How to get checkbox value RRS feed

  • Question

  • Hello community,

    I am currently working on the ribbon in an application page (SharePoint solution). I added a checkbox inside the ribbon. But now, I need to get the value of this checkbox in my JavaScript code.

    Here's my code:

    Elements.xml (representing the ribbon customization):

    <Controls Id="Dpc2013.Ribbon.ViewGroup.Controls">
      <CheckBox Id="Dpc2013.Ribbon.ViewGroup.HierarchicalView"
        Command="Dpc2013.Ribbon.Command.ShowHierarchicalView"
        Sequence="53"
        LabelText="Show Detailed View"
        ToolTipTitle="Show Detailed View"
        TemplateAlias="c1"/>
    </Controls>
    
      ...
    
      <CommandUIHandlers>
        <CommandUIHandler
          Command="Teamsquare.Dpc2013.Ribbon.Command.ShowHierarchicalView"
          CommandAction="javascript:GM.ToggleMode(this);" />
      </CommandUIHandlers>

    And here's my JS code :

    this.ToggleMode = function (obj) {
    
    	var mode = obj.checked == true ? 1 : 0;
    
    	// Send the sorting values to the server by using a callback.
    	var args = Sys.Serialization.JavaScriptSerializer.serialize({
    		Command: commands.GetData,
    		DisplayMode: mode
    	});
    
    	eval(callbacks.displayCallback);
    }

    The 'mode' variable should be set with the value of the checkbox defined in the ribbon, but how can I get its value??

    Cheers !

    Tuesday, February 5, 2013 4:18 PM