• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Using Edit Grid Checkbox Row Selection to change appvar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Edit Grid Checkbox Row Selection to change appvar

    Is there any way to cause an app variable to change, say from true to false, whenever a user has a checkbox selected that is part of an edit grid (using the widget settings "Checkbox row Selection" option) and also switch the variable back if they uncheck the box?

  • #2
    We currently do not have a behavior tied to a grid for when it has checkbox selection turned on, and we will add this to our feature request list.

    In the meantime, you can create an 'Execute Script' on startup via the behavior section to achieve this. Please make sure to name your widget.

    Code:
    var testAppVar     = getAppVar('testAppVar'),
        editGridWidget = getWidget('myEditGrid');
    
    editGridWidget.down('grid').on('selectionchange', function (sm, selected) {
        if (!Valence.isEmpty(selected)) {
            setAppVar('testAppVar', true);
        } else {
            setAppVar('testAppVar', false);
        }
    });
    
    success();
    This code declares a variable named testAppVar and initializes it to the value returned by getAppVar('testAppVar'). getAppVar is a function that retrieves an application-level variable's value and returns it. The code also declares a variable named editGridWidget and initializes it to the widget with the NAME 'myEditGrid' retrieved by calling the getWidget function.

    The code attaches an event handler to the 'selectionchange' event of the grid object which is a descendant of the object referenced by editGridWidget variable. The event handler takes two arguments, a selection model object (sm) and an array of selected records (selected).

    The event handler checks if the selected array is not empty using the Valence.isEmpty function. If it's not empty, the code sets the testAppVar application-level variable to true by calling the setAppVar function. If it is empty, the testAppVar variable is set to false.

    Comment


    • #3
      Awesome, that works great for now!

      Thank you!

      Comment

      Working...
      X