Using Orthogonal Data

This example shows how SearchBuilder can make use of orthogonal data.

The "Rating" column renders a progress bar depending on the value that it holds. SearchBuilder is unable to display progress bars in it's select elements. By setting columns.searchBuilder.orthogonal to have an orthogonal.display value of 'filter', the raw numerical data is displayed instead.

Name Position Office Rating Start date Salary
Name Position Office Rating Start date Salary
  • Javascript
  • HTML
  • CSS
  • Ajax
  • Server-side script
  • Comments

The Javascript shown below is used to initialise the table shown in this example:

var data = [ { name: 'Tiger Nixon', position: 'System Architect', salary: '320800', start_date: '2011/04/25', office: 'Edinburgh', rating: '5421' }, { name: 'Garrett Winters', position: 'Accountant', salary: '170750', start_date: '2011/07/25', office: 'Tokyo', rating: '8422' }, { name: 'Ashton Cox', position: 'Junior Technical Author', salary: '86000', start_date: '2009/01/12', office: 'San Francisco', rating: '1562' }, { name: 'Cedric Kelly', position: 'Senior Javascript Developer', salary: '433060', start_date: '2012/03/29', office: 'Edinburgh', rating: '6224' }, { name: 'Airi Satou', position: 'Accountant', salary: '162700', start_date: '2008/11/28', office: 'Tokyo', rating: '5407' }, { name: 'Brielle Williamson', position: 'Integration Specialist', salary: '372000', start_date: '2012/12/02', office: 'New York', rating: '4804' }, { name: 'Herrod Chandler', position: 'Sales Assistant', salary: '137500', start_date: '2012/08/06', office: 'San Francisco', rating: '9608' }, { name: 'Rhona Davidson', position: 'Integration Specialist', salary: '327900', start_date: '2010/10/14', office: 'Tokyo', rating: '6200' }, { name: 'Colleen Hurst', position: 'Javascript Developer', salary: '205500', start_date: '2009/09/15', office: 'San Francisco', rating: '2360' }, { name: 'Sonya Frost', position: 'Software Engineer', salary: '103600', start_date: '2008/12/13', office: 'Edinburgh', rating: '1667' }, { name: 'Jena Gaines', position: 'Office Manager', salary: '90560', start_date: '2008/12/19', office: 'London', rating: '3814' }, { name: 'Quinn Flynn', position: 'Support Lead', salary: '342000', start_date: '2013/03/03', office: 'Edinburgh', rating: '9497' }, { name: 'Charde Marshall', position: 'Regional Director', salary: '470600', start_date: '2008/10/16', office: 'San Francisco', rating: '6741' }, { name: 'Haley Kennedy', position: 'Senior Marketing Designer', salary: '313500', start_date: '2012/12/18', office: 'London', rating: '3597' }, { name: 'Tatyana Fitzpatrick', position: 'Regional Director', salary: '385750', start_date: '2010/03/17', office: 'London', rating: '1965' }, { name: 'Michael Silva', position: 'Marketing Designer', salary: '198500', start_date: '2012/11/27', office: 'London', rating: '1581' }, { name: 'Paul Byrd', position: 'Chief Financial Officer (CFO)', salary: '725000', start_date: '2010/06/09', office: 'New York', rating: '3059' }, { name: 'Gloria Little', position: 'Systems Administrator', salary: '237500', start_date: '2009/04/10', office: 'New York', rating: '1721' }, { name: 'Bradley Greer', position: 'Software Engineer', salary: '132000', start_date: '2012/10/13', office: 'London', rating: '2558' }, { name: 'Dai Rios', position: 'Personnel Lead', salary: '217500', start_date: '2012/09/26', office: 'Edinburgh', rating: '2290' }, { name: 'Jenette Caldwell', position: 'Development Lead', salary: '345000', start_date: '2011/09/03', office: 'New York', rating: '1937' }, { name: 'Yuri Berry', position: 'Chief Marketing Officer (CMO)', salary: '675000', start_date: '2009/06/25', office: 'New York', rating: '6154' }, { name: 'Caesar Vance', position: 'Pre-Sales Support', salary: '106450', start_date: '2011/12/12', office: 'New York', rating: '8330' }, { name: 'Doris Wilder', position: 'Sales Assistant', salary: '85600', start_date: '2010/09/20', office: 'Sydney', rating: '3023' }, { name: 'Angelica Ramos', position: 'Chief Executive Officer (CEO)', salary: '1200000', start_date: '2009/10/09', office: 'London', rating: '5797' }, { name: 'Gavin Joyce', position: 'Developer', salary: '92575', start_date: '2010/12/22', office: 'Edinburgh', rating: '8822' }, { name: 'Jennifer Chang', position: 'Regional Director', salary: '357650', start_date: '2010/11/14', office: 'Argentina', rating: '9239' }, { name: 'Brenden Wagner', position: 'Software Engineer', salary: '206850', start_date: '2011/06/07', office: 'San Francisco', rating: '1314' }, { name: 'Fiona Green', position: 'Chief Operating Officer (COO)', salary: '850000', start_date: '2010/03/11', office: 'San Francisco', rating: '2947' }, { name: 'Shou Itou', position: 'Regional Marketing', salary: '163000', start_date: '2011/08/14', office: 'Tokyo', rating: '8899' }, { name: 'Michelle House', position: 'Integration Specialist', salary: '95400', start_date: '2011/06/02', office: 'Sydney', rating: '2769' }, { name: 'Suki Burks', position: 'Developer', salary: '114500', start_date: '2009/10/22', office: 'London', rating: '6832' }, { name: 'Prescott Bartlett', position: 'Technical Author', salary: '145000', start_date: '2011/05/07', office: 'London', rating: '3606' }, { name: 'Gavin Cortez', position: 'Team Leader', salary: '235500', start_date: '2008/10/26', office: 'San Francisco', rating: '2860' }, { name: 'Martena Mccray', position: 'Post-Sales support', salary: '324050', start_date: '2011/03/09', office: 'Edinburgh', rating: '8240' }, { name: 'Unity Butler', position: 'Marketing Designer', salary: '85675', start_date: '2009/12/09', office: 'San Francisco', rating: '5384' }, { name: 'Howard Hatfield', position: 'Office Manager', salary: '164500', start_date: '2008/12/16', office: 'San Francisco', rating: '7031' }, { name: 'Hope Fuentes', position: 'Secretary', salary: '109850', start_date: '2010/02/12', office: 'San Francisco', rating: '6318' }, { name: 'Vivian Harrell', position: 'Financial Controller', salary: '452500', start_date: '2009/02/14', office: 'San Francisco', rating: '9422' }, { name: 'Timothy Mooney', position: 'Office Manager', salary: '136200', start_date: '2008/12/11', office: 'London', rating: '7580' }, { name: 'Jackson Bradshaw', position: 'Director', salary: '645750', start_date: '2008/09/26', office: 'New York', rating: '1042' }, { name: 'Olivia Liang', position: 'Support Engineer', salary: '234500', start_date: '2011/02/03', office: 'Argentina', rating: '2120' }, { name: 'Bruno Nash', position: 'Software Engineer', salary: '163500', start_date: '2011/05/03', office: 'London', rating: '6222' }, { name: 'Sakura Yamamoto', position: 'Support Engineer', salary: '139575', start_date: '2009/08/19', office: 'Tokyo', rating: '9383' }, { name: 'Thor Walton', position: 'Developer', salary: '98540', start_date: '2013/08/11', office: 'New York', rating: '8327' }, { name: 'Finn Camacho', position: 'Support Engineer', salary: '87500', start_date: '2009/07/07', office: 'San Francisco', rating: '2927' }, { name: 'Serge Baldwin', position: 'Data Coordinator', salary: '138575', start_date: '2012/04/09', office: 'Argentina', rating: '8352' }, { name: 'Zenaida Frank', position: 'Software Engineer', salary: '125250', start_date: '2010/01/04', office: 'New York', rating: '7439' }, { name: 'Zorita Serrano', position: 'Software Engineer', salary: '115000', start_date: '2012/06/01', office: 'San Francisco', rating: '4389' }, { name: 'Jennifer Acosta', position: 'Junior Javascript Developer', salary: '75650', start_date: '2013/02/01', office: 'Edinburgh', rating: '3431' }, { name: 'Cara Stevens', position: 'Sales Assistant', salary: '145600', start_date: '2011/12/06', office: 'New York', rating: '3990' }, { name: 'Hermione Butler', position: 'Regional Director', salary: '356250', start_date: '2011/03/21', office: 'London', rating: '1016' }, { name: 'Lael Greer', position: 'Systems Administrator', salary: '103500', start_date: '2009/02/27', office: 'London', rating: '6733' }, { name: 'Jonas Alexander', position: 'Developer', salary: '86500', start_date: '2010/07/14', office: 'San Francisco', rating: '8196' }, { name: 'Shad Decker', position: 'Regional Director', salary: '183000', start_date: '2008/11/13', office: 'Edinburgh', rating: '6373' }, { name: 'Michael Bruce', position: 'Javascript Developer', salary: '183000', start_date: '2011/06/27', office: 'Argentina', rating: '5384' }, { name: 'Donna Snider', position: 'Customer Support', salary: '112000', start_date: '2011/01/25', office: 'New York', rating: '4226' } ]; $('#example').DataTable({ columns: [ { data: 'name' }, { data: 'position' }, { className: 'f32', // used by world-flags-sprite library data: 'office', render: function (data, type) { if (type === 'display') { var country = ''; switch (data) { case 'Argentina': country = 'ar'; break; case 'Edinburgh': country = '_Scotland'; break; case 'London': country = '_England'; break; case 'New York': case 'San Francisco': country = 'us'; break; case 'Sydney': country = 'au'; break; case 'Tokyo': country = 'jp'; break; } return '<span class="flag ' + country + '"></span> ' + data; } return data; } }, { data: 'rating', searchBuilder: { orthogonal: { display: 'filter' } }, render: function (data, type, row, meta) { return type === 'display' ? '<progress title="' + data + '" value="' + data + '" max="9999"></progress>' : data; } }, { data: 'start_date' }, { data: 'salary', render: $.fn.dataTable.render.number(',', '.', 2, '$') } ], data: data, layout: { top1: 'searchBuilder' } });
var data = [ { name: 'Tiger Nixon', position: 'System Architect', salary: '320800', start_date: '2011/04/25', office: 'Edinburgh', rating: '5421' }, { name: 'Garrett Winters', position: 'Accountant', salary: '170750', start_date: '2011/07/25', office: 'Tokyo', rating: '8422' }, { name: 'Ashton Cox', position: 'Junior Technical Author', salary: '86000', start_date: '2009/01/12', office: 'San Francisco', rating: '1562' }, { name: 'Cedric Kelly', position: 'Senior Javascript Developer', salary: '433060', start_date: '2012/03/29', office: 'Edinburgh', rating: '6224' }, { name: 'Airi Satou', position: 'Accountant', salary: '162700', start_date: '2008/11/28', office: 'Tokyo', rating: '5407' }, { name: 'Brielle Williamson', position: 'Integration Specialist', salary: '372000', start_date: '2012/12/02', office: 'New York', rating: '4804' }, { name: 'Herrod Chandler', position: 'Sales Assistant', salary: '137500', start_date: '2012/08/06', office: 'San Francisco', rating: '9608' }, { name: 'Rhona Davidson', position: 'Integration Specialist', salary: '327900', start_date: '2010/10/14', office: 'Tokyo', rating: '6200' }, { name: 'Colleen Hurst', position: 'Javascript Developer', salary: '205500', start_date: '2009/09/15', office: 'San Francisco', rating: '2360' }, { name: 'Sonya Frost', position: 'Software Engineer', salary: '103600', start_date: '2008/12/13', office: 'Edinburgh', rating: '1667' }, { name: 'Jena Gaines', position: 'Office Manager', salary: '90560', start_date: '2008/12/19', office: 'London', rating: '3814' }, { name: 'Quinn Flynn', position: 'Support Lead', salary: '342000', start_date: '2013/03/03', office: 'Edinburgh', rating: '9497' }, { name: 'Charde Marshall', position: 'Regional Director', salary: '470600', start_date: '2008/10/16', office: 'San Francisco', rating: '6741' }, { name: 'Haley Kennedy', position: 'Senior Marketing Designer', salary: '313500', start_date: '2012/12/18', office: 'London', rating: '3597' }, { name: 'Tatyana Fitzpatrick', position: 'Regional Director', salary: '385750', start_date: '2010/03/17', office: 'London', rating: '1965' }, { name: 'Michael Silva', position: 'Marketing Designer', salary: '198500', start_date: '2012/11/27', office: 'London', rating: '1581' }, { name: 'Paul Byrd', position: 'Chief Financial Officer (CFO)', salary: '725000', start_date: '2010/06/09', office: 'New York', rating: '3059' }, { name: 'Gloria Little', position: 'Systems Administrator', salary: '237500', start_date: '2009/04/10', office: 'New York', rating: '1721' }, { name: 'Bradley Greer', position: 'Software Engineer', salary: '132000', start_date: '2012/10/13', office: 'London', rating: '2558' }, { name: 'Dai Rios', position: 'Personnel Lead', salary: '217500', start_date: '2012/09/26', office: 'Edinburgh', rating: '2290' }, { name: 'Jenette Caldwell', position: 'Development Lead', salary: '345000', start_date: '2011/09/03', office: 'New York', rating: '1937' }, { name: 'Yuri Berry', position: 'Chief Marketing Officer (CMO)', salary: '675000', start_date: '2009/06/25', office: 'New York', rating: '6154' }, { name: 'Caesar Vance', position: 'Pre-Sales Support', salary: '106450', start_date: '2011/12/12', office: 'New York', rating: '8330' }, { name: 'Doris Wilder', position: 'Sales Assistant', salary: '85600', start_date: '2010/09/20', office: 'Sydney', rating: '3023' }, { name: 'Angelica Ramos', position: 'Chief Executive Officer (CEO)', salary: '1200000', start_date: '2009/10/09', office: 'London', rating: '5797' }, { name: 'Gavin Joyce', position: 'Developer', salary: '92575', start_date: '2010/12/22', office: 'Edinburgh', rating: '8822' }, { name: 'Jennifer Chang', position: 'Regional Director', salary: '357650', start_date: '2010/11/14', office: 'Argentina', rating: '9239' }, { name: 'Brenden Wagner', position: 'Software Engineer', salary: '206850', start_date: '2011/06/07', office: 'San Francisco', rating: '1314' }, { name: 'Fiona Green', position: 'Chief Operating Officer (COO)', salary: '850000', start_date: '2010/03/11', office: 'San Francisco', rating: '2947' }, { name: 'Shou Itou', position: 'Regional Marketing', salary: '163000', start_date: '2011/08/14', office: 'Tokyo', rating: '8899' }, { name: 'Michelle House', position: 'Integration Specialist', salary: '95400', start_date: '2011/06/02', office: 'Sydney', rating: '2769' }, { name: 'Suki Burks', position: 'Developer', salary: '114500', start_date: '2009/10/22', office: 'London', rating: '6832' }, { name: 'Prescott Bartlett', position: 'Technical Author', salary: '145000', start_date: '2011/05/07', office: 'London', rating: '3606' }, { name: 'Gavin Cortez', position: 'Team Leader', salary: '235500', start_date: '2008/10/26', office: 'San Francisco', rating: '2860' }, { name: 'Martena Mccray', position: 'Post-Sales support', salary: '324050', start_date: '2011/03/09', office: 'Edinburgh', rating: '8240' }, { name: 'Unity Butler', position: 'Marketing Designer', salary: '85675', start_date: '2009/12/09', office: 'San Francisco', rating: '5384' }, { name: 'Howard Hatfield', position: 'Office Manager', salary: '164500', start_date: '2008/12/16', office: 'San Francisco', rating: '7031' }, { name: 'Hope Fuentes', position: 'Secretary', salary: '109850', start_date: '2010/02/12', office: 'San Francisco', rating: '6318' }, { name: 'Vivian Harrell', position: 'Financial Controller', salary: '452500', start_date: '2009/02/14', office: 'San Francisco', rating: '9422' }, { name: 'Timothy Mooney', position: 'Office Manager', salary: '136200', start_date: '2008/12/11', office: 'London', rating: '7580' }, { name: 'Jackson Bradshaw', position: 'Director', salary: '645750', start_date: '2008/09/26', office: 'New York', rating: '1042' }, { name: 'Olivia Liang', position: 'Support Engineer', salary: '234500', start_date: '2011/02/03', office: 'Argentina', rating: '2120' }, { name: 'Bruno Nash', position: 'Software Engineer', salary: '163500', start_date: '2011/05/03', office: 'London', rating: '6222' }, { name: 'Sakura Yamamoto', position: 'Support Engineer', salary: '139575', start_date: '2009/08/19', office: 'Tokyo', rating: '9383' }, { name: 'Thor Walton', position: 'Developer', salary: '98540', start_date: '2013/08/11', office: 'New York', rating: '8327' }, { name: 'Finn Camacho', position: 'Support Engineer', salary: '87500', start_date: '2009/07/07', office: 'San Francisco', rating: '2927' }, { name: 'Serge Baldwin', position: 'Data Coordinator', salary: '138575', start_date: '2012/04/09', office: 'Argentina', rating: '8352' }, { name: 'Zenaida Frank', position: 'Software Engineer', salary: '125250', start_date: '2010/01/04', office: 'New York', rating: '7439' }, { name: 'Zorita Serrano', position: 'Software Engineer', salary: '115000', start_date: '2012/06/01', office: 'San Francisco', rating: '4389' }, { name: 'Jennifer Acosta', position: 'Junior Javascript Developer', salary: '75650', start_date: '2013/02/01', office: 'Edinburgh', rating: '3431' }, { name: 'Cara Stevens', position: 'Sales Assistant', salary: '145600', start_date: '2011/12/06', office: 'New York', rating: '3990' }, { name: 'Hermione Butler', position: 'Regional Director', salary: '356250', start_date: '2011/03/21', office: 'London', rating: '1016' }, { name: 'Lael Greer', position: 'Systems Administrator', salary: '103500', start_date: '2009/02/27', office: 'London', rating: '6733' }, { name: 'Jonas Alexander', position: 'Developer', salary: '86500', start_date: '2010/07/14', office: 'San Francisco', rating: '8196' }, { name: 'Shad Decker', position: 'Regional Director', salary: '183000', start_date: '2008/11/13', office: 'Edinburgh', rating: '6373' }, { name: 'Michael Bruce', position: 'Javascript Developer', salary: '183000', start_date: '2011/06/27', office: 'Argentina', rating: '5384' }, { name: 'Donna Snider', position: 'Customer Support', salary: '112000', start_date: '2011/01/25', office: 'New York', rating: '4226' } ]; new DataTable('#example', { columns: [ { data: 'name' }, { data: 'position' }, { className: 'f32', // used by world-flags-sprite library data: 'office', render: function (data, type) { if (type === 'display') { var country = ''; switch (data) { case 'Argentina': country = 'ar'; break; case 'Edinburgh': country = '_Scotland'; break; case 'London': country = '_England'; break; case 'New York': case 'San Francisco': country = 'us'; break; case 'Sydney': country = 'au'; break; case 'Tokyo': country = 'jp'; break; } return '<span class="flag ' + country + '"></span> ' + data; } return data; } }, { data: 'rating', searchBuilder: { orthogonal: { display: 'filter' } }, render: function (data, type, row, meta) { return type === 'display' ? '<progress title="' + data + '" value="' + data + '" max="9999"></progress>' : data; } }, { data: 'start_date' }, { data: 'salary', render: $.fn.dataTable.render.number(',', '.', 2, '$') } ], data: data, layout: { top1: 'searchBuilder' } });

In addition to the above code, the following Javascript library files are loaded for use in this example:

    The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:

    This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:

    td.f32 .flag { vertical-align: middle; }

    The following CSS library files are loaded for use in this example to provide the styling of the table:

      This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.

      The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side processing scripts can be written in any language, using the protocol described in the DataTables documentation.

      Other examples