public static JsonDataSource CreateDataSourceFromWeb() { var jsonDataSource = new JsonDataSource(); // Specify the endpoint. jsonDataSource.JsonSource = new UriJsonSource( new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")); var root = new JsonSchemaNode(); root.NodeType = JsonNodeType.Object; var customers = new JsonSchemaNode() { NodeType = JsonNodeType.Array, Name = "Customers", Selected = true }; customers.AddChildren(new[] { new JsonSchemaNode(new JsonNode("CustomerID", true, JsonNodeType.Property, typeof(string))) { DisplayName = "Customer ID" }, new JsonSchemaNode() { Name = "CompanyName", Selected = true, NodeType = JsonNodeType.Property, Type = typeof(string) }, new JsonSchemaNode(new JsonNode("ContactTitle", true, JsonNodeType.Property, typeof(string))), new JsonSchemaNode(new JsonNode("Address", false, JsonNodeType.Property, typeof(string))) }); root.AddChildren(customers); jsonDataSource.Schema = root; // The schema is built, you do not have to call the Fill method to populate the Field List. // The Designer calls the Fill method automatically when a document is generated for preview. // jsonDataSource.Fill(); return(jsonDataSource); }
private JsonDataSource CreateDataSourceFromWeb() { var jsonDataSource = new JsonDataSource(); jsonDataSource.JsonSource = new UriJsonSource(new Uri("http://northwind.servicestack.net/customers.json")); var root = new JsonSchemaNode(); root.NodeType = JsonNodeType.Object; var customers = new JsonSchemaNode() { NodeType = JsonNodeType.Array, Name = "Customers", Selected = true }; customers.AddChildren(new[] { new JsonSchemaNode(new JsonNode("CustomerID", true, JsonNodeType.Property, typeof(string))) { DisplayName = "Customer ID" }, new JsonSchemaNode() { Name = "CompanyName", Selected = true, NodeType = JsonNodeType.Property, Type = typeof(string) }, new JsonSchemaNode(new JsonNode("ContactTitle", true, JsonNodeType.Property, typeof(string))), new JsonSchemaNode(new JsonNode("Address", false, JsonNodeType.Property, typeof(string))) }); root.AddChildren(customers); jsonDataSource.Schema = root; //Retrieve data from the JSON data source jsonDataSource.Fill(); return(jsonDataSource); }