SMART datagrid v.1 > Classes > DataField

Back  Forward

DataLudi.DataField.sameValues  method

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

It is compared less strictly than equalValues. Please refer to the table below. 

function sameValues (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, null, ''(empty string), the rest should also be one of them. Other cases will compare by equality operator(==).
NUMBERIf one side is NaN, the reset should also be NaN. Other cases will compare by equality operator(==).
BOOLEANInterpret and compare both values as Boolean.
DATETIMEIf 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).sameValues(newVal, orgVal)) {
                ds.setValue(row, f, newVal);
            }
        }
    });
See Also
equalValues
Examples
Restore Data Rows