Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Settings

Kiarash edited this page Feb 19, 2015 · 9 revisions

Settings

DataTabled OData plugin options. You can load a object with the default settings

// Default settings
var default  = new DataTableOData.Settings();
var default  = new DataTableOData.Settings('url');

General

General options

Url

Name Type Default Requiered Sample
url string emtpy true '/odata/NorthwindModel'

This is used as base url for every ajax request. This option is requiered

Order

Name Type Default
queryOrder boolean true

Whether the odata $order parameter is supported or not

Select

Name Type Default
querySelect boolean true

Whether the odata $select parameter is supported or not. Turn on for less overhead.

OData Operators

Name Type Default
mapOperators string[] ODataComparisonOperatorsMap

You can set custom compare operator if you like. The array must match the postions of the original map. This is mainly used for the column search function.

The default search input would be: "> 16" instead of 'gt 16' Both will be displayed as followed in the query:

// Options
{ data: "Name" },

// Search
var search = "== Peter";
dt.columns[1].search(search);

// The query will look like
$filter=Name eq 'Peter' and ...

Build-in Maps

// Included maps
DataTableOData.ODataComparisonOperators    = ["eq", "ne", "gt", "ge", "lt", "le", "has"];
DataTableOData.ODataComparisonOperatorsMap = ["==", "!=", ">",  ">=",  "<", "<=", "has"];

Column Search

Setting Type Default Options
searchColumns boolean true
searchColumnsPlace string thead thead / tfoot

Whether column search is enabled or not. If is enabled a input for every column is created. You can control the position of the inputs row with the searchColumnsPlace parameter.

Column

This options are set for every column.

Example:

// Colum names 
{ data: "Name" },
or
{ name: "Name" },

// samples
{ data: "Name", type: "number", searchMethod: "contains" },
{ data: "Age" , type: "number" },
{ data: "Dogs", type: "number" },

Search Method

Name Type Default Options
searchMethod string empty contains / endswith / startswith

If this is set the input value is placed inside this function.

Example:

// Options
// If searchMethod is set for this column
{ data: "Phone", type: "number", searchMethod: "contains" },

// Search
var search = 123456;
dt.columns[1].search(search);

// The query will look like this
$filter=contains(Phone, 123456) and ...

Name / Data

You can use the name and / or data option in the column settings. The difference is that dataTables uses internaly a array for the columns if the data paramter is missing. This means that the result from a OData request must exact match the order and the count of the columns in the table. This only wokrs if the OData $select method is supported. Best is you set both, then you can alway choose this via a flag.

If the OData method $select is not supported then you have to use the data paramter, as the resault set may not match the column order and count of your table.

Name Type Default Info
name string empty If only name is passed than it has to match the OData property name
data string empty OData property name

This settings are build in DataTables options

Type

Name Type Default
type string empty

Type of the column data. If this is not a numeric/number type than on a column search the value will be escaped

This setting is a build in DataTables option

Clone this wiki locally