[Data Grid] how to enable/disable column by specific condition?

Forge Component
(26)
Published on 31 Jul by OutSystems R&D
26 votes
Published on 31 Jul by OutSystems R&D

Hi there.

I having a trouble on how to enable column according to condition.

For example, I have a radio button outside grid. I want to use it as a trigger the column inside grid to be enable or disable.

I have tried these following 2 methods but have no luck.

 1.I created function inside AdvancedFormat property using IsReadOnly: disableController();

    but the function was call only the first render.(it will not call again when I click on radio button onchange event with refreshGrid.)

2.I added beginningEdit event inside grid. It was called properly but after the function ended, the result was overwrited by function inside grid.

So, if anyone know how to implement it, please help.

Thanks you.





Solution

Hello Chaiwat.

I do not have ideas that change the value of enable / disable, but I think you can cancel the input.

----- GridContainer> AdvancedFormat ------

"onBeginningEdit: changeEditable"

----- javascript function ----

var radioButton = true;

trueButtonClick = function(){

    radioButton = true;

}

falseButtonClick = function(){

    radioButton = false;

}

changeEditable = function (e) {

     // get the row and col

     var row = e._rng._row;

     var col = e._rng._col;

     // get the row data

     var checkValue = e._p._rows [row] ._ data.PO_No;

     // check process

     if (checkValue == "XXX" && col === 1 && radioButton) {

         return false;

     }

     else {

         return this.beginningEdit.raise (this, e), e.cancel;

     }

}



*In the case of Paste, I think that I can do it by writing a function similar to this.

----- GridContainer> AdvancedFormat ------
"onPastingCell:changePasting"

----- javascript function ----
changePasting = function(e){
...
    else{
        return this.pastingCell.raise(this, e), !e.cancel
    }


I hope you find it useful.

Solution

Yoichi Hasegawa wrote:

Hello Chaiwat.

I do not have ideas that change the value of enable / disable, but I think you can cancel the input.

----- GridContainer> AdvancedFormat ------

"onBeginningEdit: changeEditable"

----- javascript function ----

var radioButton = true;

trueButtonClick = function(){

    radioButton = true;

}

falseButtonClick = function(){

    radioButton = false;

}

changeEditable = function (e) {

     // get the row and col

     var row = e._rng._row;

     var col = e._rng._col;

     // get the row data

     var checkValue = e._p._rows [row] ._ data.PO_No;

     // check process

     if (checkValue == "XXX" && col === 1 && radioButton) {

         return false;

     }

     else {

         return this.beginningEdit.raise (this, e), e.cancel;

     }

}



*In the case of Paste, I think that I can do it by writing a function similar to this.

----- GridContainer> AdvancedFormat ------
"onPastingCell:changePasting"

----- javascript function ----
changePasting = function(e){
...
    else{
        return this.pastingCell.raise(this, e), !e.cancel
    }


I hope you find it useful.

Thank you very much. It's worked as charm.