Disabling a row in a Grid based off of a value in the source

14. July 2009

So I needed to disable a row in a Grid based on a value in one of the columns. I found an example on Microsoft’s website and wanted to document it here:

Overwriting the ‘active’ method on the datasource:

public int active()
{
    int ret;

    ret = super();
    if (MDSI_ConfigurationLine.MDSI_ConfigurationLineStatusId == 'CLOSED')
    {
        MDSI_ConfigurationLine_ds.allowEdit(false);
    }
    else
    {
        MDSI_ConfigurationLine_ds.allowEdit(true);
    }

    return ret;
}

You need to make sure you have the else to allowEdit otherwise all of rows will be disabled.

Microsoft Dynamics Ax 2009