Hello Roy,
Currently, our DataForm support only binding to CLR objects. What it currently lack is a suitable extension point to plug the custom generation logic as it currently it requires PropertyInfo properties. However, with the upcoming release (in the mid of Septemeber) we will add an extension point.
With the updated version you would be able to use the following snippet:
public
class
JSONMetadataProvider : PropertyMetadataProviderBase
{
private
List<EntityProperty> entityProperties =
new
List<EntityProperty>();
public
override
List<EntityProperty> EntityProperties
{
get
{
return
entityProperties;
}
}
public
override
void
Initialize(
object
source)
{
var data = JObject.Parse(source.ToString());
foreach
(JObject item
in
data[
"questions"
])
{
foreach
(var jProperty
in
item.Properties())
{
var metadata =
new
EntityPropertyMetadata()
{
Group = ...,
Header = ...,
PropertyType = ...,
PropertyType = ...,
...
};
var property =
new
JsonEntityProperty(jProperty, item, metadata);
}
}
}
}
public
class
JsonEntityProperty : EntityProperty
{
private
JProperty property;
public
JsonEntityProperty(JProperty property,
object
item, EntityPropertyMetadata metadata) :
base
(property, item, metadata)
{
this
.property = property;
}
public
override
object
OriginalValue
{
get
{
return
property.Value;
}
}
public
override
void
Commit()
{
//TODO: implement
throw
new
NotImplementedException();
}
}
The setup of the DataForm will look like that:
We will also issue an article describing the specific case of binding the json.
Thank you for bringing the use case to our attention. I have updated your telerik points acordingly
Regards,
Tsvyatko
Telerik by Progress
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items