Wijmo UI for the Web
dataParser Field

Type: wijmo.grid.IDataParser

Data converter that is able to translate values from a string representation to column data type and back.

Syntax
Javascript (Usage) 
var instance; // Type: wijmo.grid.IColumn;
var value; // Type: IDataParser
value = instance.dataParser;
Javascript (Specification) 
var dataParser : IDataParser;
Example
var myBoolParser = {
    parseDOM: function (value, culture, format, nullString) {
        return this.parse(value.innerHTML, culture, format, nullString);
    },
    parse: function (value, culture, format, nullString) {
        if (typeof (value) === "boolean")  return value;
        if (!value || (value === " ") || (value === nullString)) {
            return null;
        }
        switch (value.toLowerCase()) {
            case "on": return true;
            case "off": return false;
        }
        return NaN;
    },
    toStr: function (value, culture, format, nullString) {
        if (value === null)  return nullString;
            return (value) ? "on" : "off";
        }
    }
}
$("#element").wijgrid({ columns: [ { dataType: "boolean", dataParser: myBoolParser } ] });
Remarks
If undefined, than the built-in parser for supported datatypes will be used.
Browser Compatibility
7
5
5

See Also

Reference

IColumn Interface

 

 


© 2013 All Rights Reserved.

Send comments on this topic.