On Data Grid Web how can I enable button on checkbox click from grid ?
Question

I found a code from one of the forum article but somehow it does not enable the button.



GridOS.SelectionFeature.updateSelectedBntState = function (gridId, btn) {

    var _selectedItems = GridOS.SelectionFeature.getSelectedElements(gridId, false);

    var _checkedItems =  GridOS.SelectionFeature.getCheckedItemsData();

    var _selectBtn = [];

    if (btn) {

        if (btn.getAttribute('isEnabled') === 'true')

            _selectBtn.push(btn);

    }

    else {

        var qry = '.SelectedItemsButton[gridId=' + gridId + ']';

        if (gridId && document.querySelector(qry)) {

            qry = '.SelectedItemsButton[gridId=' + gridId + '][isEnabled=true]';

        }

        else {

            qry = '.SelectedItemsButton[isEnabled=true]';

        }

        [].forEach.call(document.querySelectorAll(qry), function (p) {

            _selectBtn.push(p);

        });

    }

    if (_selectBtn.length > 0) {

        var isDirty_2 = false;

        var canSendErrorFreeRow_2 = (_selectBtn[0].getAttribute("data-errorfree") === "true");

        var sendAllSelectedRows_1 = (_selectBtn[0].getAttribute("data-sendAllSelectedRows") === "true");

        var hasError_2 = _selectedItems

            .filter(function (p) { return GridOS.dirtyItemsFeature.isDirtyItem(p); })

            .some(function (p) {

            isDirty_2 = true;

            return !GridOS.dirtyItemsFeature.isValid(p);

        });

        _selectBtn.map(function (p) {

            if (sendAllSelectedRows_1 && _checkedItems.length > 0) {

                p.classList.remove('wj-disabled');

            }

            else if (isDirty_2 && (canSendErrorFreeRow_2 || !hasError_2)) {

                p.classList.remove('wj-disabled');

            }

            else {

                p.classList.add('wj-disabled');

            }

        });

    }

}








Hello,


I would suggest using OutSystems events, adding an event on the OnClick action for the checkbox that sets a local variable to True/False according to your needs. That local variable can be put as a Enabled property of the button and it should do the job.


Regards,

Bogdan

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.