parsing - Manually parse json data according to kendo model -
any built-in ready-to-use solution in kendo ui parse json data according schema.model
? maybe kendo.parsedata(json, model)
, return array of objects?
i searching , couldn't find built-in. however, using model.set
apparently uses each field's parse logic, ended writing function works pretty good:
function parse(model, json) { // initialize model json data quick fix since // setting id field doesn't seem work. var parsed = new model(json); var fields = object.keys(model.fields); (var i=0; i<fields.length; i++) { parsed.set(fields[i], json[fields[i]]); } return parsed; }
where model
kendo.data.model
definition (or datasource.schema.model
), , json
raw object. using or modifying accept , return arrays shouldn't hard, use case needed single object parsed @ time.
Comments
Post a Comment