SMART datagrid v.1 > Classes > DataField

Back  Forward

DataLudi.DataField.equalValues  method

Return true if the two values specified by parameter value1, value2 are the same. 

It is compared more strictly than sameValues. Please refer to the table below. 

function equalValues (value1: *, value2: *): Boolean;
Returns
Boolean
Parameters
value1 - *.
value2 - *.
Table-1  The comparison of each data type
Data typeThe standard of determining the same value
TEXTIf one side is undefined, the reset should also be undefined. Other cases will compare by equality operator(==).
NUMBERIf one side is undefined, the reset should also be undefined. If one side is NaN, the reset should also be NaN. Other cases will compare by equality operator(==).
BOOLEANIf one side is undefined, the reset should also be undefined. Other cases will compare by equality operator(==).
DATETIMEIf one side is undefined, the reset should also be undefined. If one side is not Date object, the reset should not be Date object either. Other cases will compare by Date.getTime().
Code -1
    $('#setValue').click(function () {
        var row = grid.focusedDataRow();
        
        if (row >= 0) {
            var f = ds.getFieldIndex('quantity');
            var newVal = $('#quantity').val();
            var orgVal = ds.getValue(r, f);
            
            // Change only if the values are different.
            if (!ds.getField(f).equalValues(newVal, orgVal)) {
                ds.setValue(row, f, newVal);
            }
        }
    });
See Also
sameValues
Examples
Restore Data Rows