We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27519
    • 275 Posts
    I’m stuck with the behaviour of checkboxes in ExtJs.

    I have a grid which displays data of certain services. A service can be refundable, which is indicated by a checkbox. There are add and update windows for services, callable from the grid. Basically the standard setup as found in other components.

    For the add service window the checkbox works well. When the checkbox is checked and the data is written to the database, the database shows a "Y" indicating that the service is refundable.

    However, when I select a refundable service from the grid and choose "Update" from the menu, all data is correctly displayed except for the checkbox, which is not checked (it should be as the service is refundable). Using the Chrome debugger I can see that all data is correctly transported to the form but the checkbox doesn’t seem to pick that up and adjust its setting accordingly. The definition for the checkbox is:
    	xtype: 'checkbox'
    	,fieldLabel: _('services.refundable')
    	,boxLabel: ''
    	,name: 'refundable'
    


    I tried experimenting with the "inputValue" config property (inputValue: ’Y’) but that doesn’t seem to make any difference.

    Am I missing a subtlety of the checkbox?

    Thanks.

      MODx Revolution / MAMP / OS X
      • 28215
      • 4,149 Posts
      How are you pre-setting the value for the checkbox? It requires the checked: true property to mark it as set.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 27519
        • 275 Posts
        Ok. Thans for your reply. I got it working now.

        If the refundable value is "Y", I set checked to true.

        I was confused - and still am - about this "inputValue" config param...
          MODx Revolution / MAMP / OS X
          • 28215
          • 4,149 Posts
          inputValue tells Ext what to set the value="" attribute of the input to. So, you are using "Y", which says, when checked, send the value as "Y".

          So, these are the same:

          <input type="checkbox" name="funtimes" value="Heck Yes!" checked="checked" />
          


          In Ext:
          {
            xtype: 'checkbox'
            ,name: 'funtimes'
            ,inputValue: 'Heck Yes!'
            ,checked: true
          }


          Most people just use 1 as the inputValue.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 27519
            • 275 Posts
            Got it. Thanks!
              MODx Revolution / MAMP / OS X