Wijmo UI for the Web
dataParser Option

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) 
$(function () {
    
    // Get value
    var returnsValue; // Type:  wijmo.grid.IDataParser
    returnsValue = $(".selector").c1field("option", "dataParser");
    
    // Set value
    var newValue; // Type:  wijmo.grid.IDataParser
    $(".selector").c1field("option", "dataParser", newValue);
        
});
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

options type
c1field jQuery Widget

 

 


© 2013 All Rights Reserved.

Send comments on this topic.