This project is read-only.
This wiki should help you learn all the possible configurations you can pass to the ODataQueryBuilder.

Example

var createdQueryBuilder = new OData.explorer.DataExplorer(
                {
                    // An array containing the different endpoints.
                    endpoints: [
                        {
                            name: 'Northwind',
                            url: 'http://services.odata.org/Northwind/Northwind.svc',
                        },
                        {
                            name: 'OData',
                            url: 'http://odataservices.azurewebsites.net/OData/OData.svc',
                        }
                    ],
                    encodeUrlComponents: true,
                    hideOrderbyFilters: true,
                    hideColumnFilters: false,
                    hideExpandFilters: false,
                    // Overwrite the default onUrlChange callback.
                    onUrlChange: function (url) {
                        console.log(url);
                    },
                    // Overwrite the default onSubmit callback.
                    onSubmit: function (url) {
                        return url;
                    },
                    // Overwrite the default onResults callback.
                    onResults: function (data) {
                        return (JSON.stringify(data, null, 4));
                    },
                    // Overwrite the default onError callback.
                    onError: function (error, url) {
                        console.log(url + '\t' + JSON.stringify(error));
                    }
}); 

endpoints

  • url: the url with the OData endpoint
  • name (optional): the name to be displayed in the dropdown menu. Otherwise the Url will be used.
  • provider (optional): a function returning the cached json $metadata about the OData endpoint. For more information about how to cache the endpoint metadata please see the Demos

encodeUrlComponents (Default: true)

If false it does not encode the user inputs in the text fields.

Example:
  • If encodeUrlComponents = false then the url will look like this http://services.odata.org/Northwind/Northwind.svc/Categories?$filter=CategoryName eq 'hello world'
  • If encodeUrlComponents = true then the url will look like this http://services.odata.org/Northwind/Northwind.svc/Categories?$filter=CategoryName eq 'hello%20world'

hideOrderbyFilters (Default: false)

If true, the order by filter will not be displayed.

hideColumnFilters (Default: false)

If true, the column selector filter will not be displayed.

hideExpandFilters (Default: false)

If true, the expand filter will not be displayed.

onUrlChange

It allows to get a callback every time there is a change in the OData url that the user is constructing.

Example:
onUrlChange: function (url) {   console.log(url);  },
 

onSubmit

A callback for when the search button is pressed by the user.
  • If nothing or false is returned, then the library will not fetch the results using its own JavaScript query method.
  • If a new url is returned, it will be used to fetch the data using its own JavaScript method.

It is useful when for example you want to fetch the data using the server to bypass some cross-domain exceptions or password permissions.

onSubmit: function (url) {   return url;  }
 

onResults

A callback for when the result data is returned by the JavaScript internal call. It allows the user to display it in a different way than the custom table behavior.
  • If nothing or false is returned, then the library will not display the results in the <div id="results"/> container.
  • If something is returned, it will be displayed in the <div id="results"/> container.

onResults: function (data) {  return (JSON.stringify(data, null, 4));  }
 

onError

A callback when an error occurs, during the JavaScript method that fetch the data from the service, based on the query passed to it.
onError: function (error, url) {  console.log(url + '\t' + JSON.stringify(error)); }
 

Last edited Apr 21, 2014 at 8:38 AM by howang, version 1

Comments

No comments yet.