1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-02 14:24:11 +01:00
Commit Graph

701 Commits

Author SHA1 Message Date
Allan Jardine
9f1cae4528 Internal: Refactor sort listener
- Think this code was in DataTables 1.0 and has been relatively
  untouched! A refactor allows it to be more readable and smaller when
  compressed (about 450 bytes saved)
2013-05-16 18:13:37 +01:00
Allan Jardine
682aa73d56 Internal: Refactor ARIA sorting attributes
- How the Aria sorting attributes were controlled, was ugly! Was in bad
  need of a refactor, which has now had. About 150 bytes (compressed)
  saved.
2013-05-16 17:37:34 +01:00
Allan Jardine
4913226456 Internal: Refactoring the sort functions for invalidation
- invalidation is going to play an important part in the new API, with
  the ability to invalid the cached data for sorting, filtering, display
  etc so we need to be able tos upport this in the core.

- In fairness the sorting didn't actually need invalidation because it
  would always get data on every sort, which is bad for performance -
  proper invalidation and caching will resolve this. Which is what has
  been implemented here.

- I had expected (hoped) to be able to save a bit of space in the
  refactor, but only aorund 100 bytes (compressed) saved, which will
  probably be lost when the invalidation is fully implemented in the
  API. Still, better performance, tidier code, and no extra space...

Fix: Sorting classes now show multi column sorting when a column is
defined to sort over multiple columns (sortData). Previously it would
only show the first column.
2013-05-16 17:16:04 +01:00
Allan Jardine
67d19ac9e4 Dev: Fix issue with the last commit which introduced an error witht he
classes calculated for display
2013-05-16 17:15:14 +01:00
Allan Jardine
b12ffb1dab New: row.add() and rows.add() methods for the new API
- Two new methods for the new API to allow new data (rows) to be added
  to the table.

  - row.add() - Add a single row to the table. object, array, jQuery
    object or TR node can be passed in.

  - rows.add() - Add one or more rows to the table from a source array.
    An array or jQuery object must be passed in, containing objects,
    arrays, or TR nodes (or any combination thereof).

- Should be noted that this is iterated over all tables in the current
  API context, so care should be taken when adding a node to multiple
  tables, since it will be moved between them. Equally, when adding
  data, the original object reference is retained, so changing it in one
  table will change it in all!

- These two methods effectively replace fnAddData from the old API.
  fnAddData had a few issues with distingusihing a multiple row add and
  a single row add, since arrays could be used for both (indeed, it
  simply couldn't cope with something like using a single integer as
  reference for a data object, which can now be done in 1.10). The two
  new methods sidestep this problem by providing one method for multiple
  row add, and another for single row add - the developer needs to know
  that the plural has meaning here!
2013-05-16 10:26:08 +01:00
Allan Jardine
5548d09ecd Merge branch 'patch-35' of https://github.com/timtucker/DataTables into 1_10_wip 2013-05-15 15:09:23 +01:00
Allan Jardine
89b2404511 New: columns().order() method for the new API
- I think it makes intuative sense to be able to tell the table to order
  on the columns given by the selector, which is exactly what this
  method does.
2013-05-15 12:02:57 +01:00
Tim Tucker
aa70a483d4 Make fewer calls to $.inArray when assigning sort classes
Only call once each to check to see sort ascending / sort descending is is active.  (And only check for the descending class if we didn't find the ascending class)

Should also lead to smaller minified code.
2013-05-15 07:58:25 -03:00
Allan Jardine
d9119fc3cb New: destroy() method for the new API
- Addition of a destroy method for the new API, effectively replacing
  fnDestroy from the old API.

- The functionality is identical to fnDestroy, but it has been
  refactored to make better use of jQuery and allow for better
  compression (should be 1/4 - 1/2 KiB saved)
2013-05-15 11:34:40 +01:00
Allan Jardine
c211a74079 Dev: Tidy up new settings() method, doesn't actually need an iterator 2013-05-14 08:52:50 +01:00
Allan Jardine
d051a17926 New: $, clear, settings, on, one and off methods for new API
- $ - perform a jQuery selector on the nodes in the table (matching the
  $ method from the old API).

- clear - clear the table completely (replaces fnClearTable).

- settings - get an array of the settings objects for the tables used in
  the API instance.

- on - jQuery event listener proxy. Use for table specific events
  ('draw', 'xhr' etc).

- one - jQuery event listener proxy (single event).

- off - jQuery event unlistener proxy.
2013-05-14 08:47:06 +01:00
Allan Jardine
30c6a45067 Dev: Refector _fnGetDataMaster and _fnClearTable to be shorter and clearer 2013-05-14 08:46:21 +01:00
Allan Jardine
bd804fdcb8 New: child row API methods for showing / hiding child rows
- Showing and hiding details about a row in a child row is very useful
  and proven to be a popular part of DataTables. This commit provides
  that ability in the new API and extends it. It also fully modularises
  the child rows aspects, so it could be removed from the core without
  effecting any other aspects (it may be moved into a seperate file in
  future).

- This will effectively replace fnOpen, fnClose and fnIsOpen

- Added methods:
  - row( selector, opts ).child()
  - row( selector, opts ).child( str, class )
  - row( selector, opts ).child( str, class ).show()
  - row( selector, opts ).child( str, class ).hide()
  - row( selector, opts ).child.show()
  - row( selector, opts ).child.hide()
  - row( selector, opts ).child.isShown()

- Note that unlike the old API you need to specify the data first, and
  then use the show() method to show the child row. This allows the
  details rows to be configured before they are actually shown.

- Additionally multiple child rows can be attached to a parent (pass
  `str` (from above) as an array to use this feature. API plug-ins could
  use this ability to show fully nested tables.

- Not just a string can be passed in now, but also a TR node which will
  actually be used (rather than put into a nested row), any other type
  of node (which will be inserted into a wrapper row/cell) or a jQuery
  object.
2013-05-07 17:56:07 +01:00
Allan Jardine
ed34f7972d New: row() methods - operate on a single row.
- The rows() method allows operations on multiple rows with a single
  call, this new singualr option, `row()` performs operations on a
  single row, allowing fine grain control and easy access to certain
  aspects. For example. `rows().data()` will return an array of data
  objects, even if there is only one row as a result of the selector,
  while `row().data()` will return the data object directly.

- Impletemented thus far:

  - row()
  - row().node()
  - row().cells()
  - row().data() - get only as of yet
  - row().index()
  - row().remove()
2013-05-06 07:14:43 +01:00
Allan Jardine
955eb2cd99 Internal: Update the the filtering input control to update itself on filter
- Previously it was the domain of the filtering caller to update the
  global filtering input element (fnFilter or the keypress handler
  specifically), but in keeping with the drive towards modularity, it
  should be the control itself that updates when needed.

- This is done by listening for the `filter` event from the table and
  updating the display as needed. It is a touch less efficent since the
  same value might be written as what is already there, but it reduces
  code size and complexity.
2013-04-29 07:58:53 +01:00
Allan Jardine
d7058eb45d New: search() and columns().search() API methods
- Ability to filter the table through the new API.

- This effectively replaces the fnFilter method of the old API.

- Note that one capability which has been removed from the old API is the
  ability to not show the new filter on the filtering input elements. I
  can't see any use for that feature to be honest, so it has been
  dropped. The filtering inputs always show the global filter state now.

- Additionally, note that we've been forced to call this `search` here
  rather than `filter` since there is a `filter` method for the API
  collection instance. This might be revisted before release.
2013-04-29 07:51:41 +01:00
Allan Jardine
2b0a321dd2 New: rows().remove() API method
- Remove (delete) selected rows from the table.

- This effectively replaces the fnDeleteRow API method of the old API.
2013-04-29 07:50:43 +01:00
Allan Jardine
a767c05f1d New: column.index() API method for translating column indexes
- The fnVisibleToColumnIndex and fnColumnIndexToVisible plug-in API
  methods for the old API were very useful for transforming the visible
  column index to the actual index, and the return. This adds that
  capability to the new API.
2013-04-28 18:31:15 +01:00
Allan Jardine
7b6ebd63de New: columns.adjust() API method.
- Recalculate the "ideal" column sizes for the table. Might want this
  after a column visiblity change for example

- Replaces the fnAdjustColumnSizing method.
2013-04-28 10:23:43 +01:00
Allan Jardine
bbb423ee75 New: API method columns().visible() - get / set column visiblity
- This effectively replaces the old fnSetColumnVis method (a shim will
  be put in place along with the shim for the rest of the old API). It
  has added get abilities, and the option, like the rest of the new API
  to work on multiple tables / columns with a single call depending on
  the context and selector.
2013-04-28 10:14:04 +01:00
Allan Jardine
8e1bf972d4 New: columns().data() API method - get the data for the selected columns 2013-04-28 09:05:03 +01:00
Allan Jardine
68ea9af828 New - rows().cells(), columns.cells() API methods.
- row options for column selector

- Selectors (table, rows and columns) now held in a single file, sharing
  structure. A more unified API is used, with row options also being
  allow for columns, through the use of the second parameter for the
  columns() method, which will effect how a column function can act upon
  rows (for example, the order of the rows when getting data or nodes).

- Dev: tables() is no longer an iterator - using an `iterator()` method
  with options which are suitable for the different types of iteration
  the API needs.
2013-04-28 08:53:05 +01:00
Allan Jardine
b1b4b58a9a Internal - remove _fnGetTrNodes
- Not used anywhere outside the old API, which is going to be shimed to
  the new one, so we can simply drop it.
2013-04-23 10:21:48 +01:00
Allan Jardine
01bc1f728d Internal - store cell reference | remove _fnGetTdNodes
- We use the cell nodes form the table body in a number of places, and
  increasing with the new API, so rather than just storing a reference
  to the hidden cells, we should just store a reference to all cells and
  use them, cleaning up a number of other areas - in particular
  _fnGetTdNodes which is no longer needed

- Should do something similar for _fnGetTrNodes

- Disabled sort classes for the moment as that can be rewritten to be
  more efficient. It did use _fnGetTdNodes, but doesn't need to now.

- API fnSetColumnVis and fnUpdate will be broken at the moment, until
  merged into the new API.
2013-04-23 09:50:59 +01:00
Allan Jardine
bb75f22233 Dev fix - Inverted logic for the information string 2013-04-23 09:50:23 +01:00
Allan Jardine
a3b90fd0cc New: API methods rows().nodes(), rows().data() and columns().header()
- rows().nodes() - Get the TR nodes for the selected rows
- rows().data() - Get the data for the selected rows
- columns().header() - Get the header cells for the selected columns

- This also introduces the `iterator` method to the API instance, which
  can be used to loop over selected columns / rows, for the context
  (tables), returning a flat array / API instance.
2013-04-23 08:49:06 +01:00
Allan Jardine
fcc7d4a78d Internal - refactor of table information control 2013-04-22 18:56:20 +01:00
Allan Jardine
cdd82a9d0e Internal - refactor processing display
- Simple refactor into the more mordern 'style', only saves about 100
  bytes, but the code looks much cleaner.
2013-04-22 09:09:14 +01:00
Allan Jardine
414abff7e6 Dev - fix attributes for empty row weren't being applied 2013-04-22 09:08:49 +01:00
Allan Jardine
73e265218e Internal - Small refector of fnDraw
- Use variable aliases to allow better compression
- Replace body append code with jQuery code. Much simpiler, and only
  a very small performance hit (around 1mS for a draw of 100 records).
2013-04-22 08:58:28 +01:00
Allan Jardine
63d9f3f21e Internal - Refactor
- Remove the settings._iDisplayEnd parameter finally, using only
  fnDisplayEnd() is needed, and the end point is calculated on-the-fly
  when needed (which is not often and it is not expensive). This also
  means that the internal method `_fnCalculateEnd` can be dropped
  completely.

- Refactoring the empty cell in _fnDraw
2013-04-21 20:02:23 +01:00
Allan Jardine
09761bfdef New - Rows and Columns selectors
- columns() and rows() introduced with their selector components. They
  don't have any additional funtionality at this time other than just
  being able to selector rows and columns (returning arrays of indexes),
  but the principle is now in place, and the additional functions can be
  fleshed out.

- Moving to use a work in process branch, as some aspects of DataTables
  may break as this work continues, and certainly the files etc are all
  in flux
2013-04-21 16:37:38 +01:00
Allan Jardine
a077d24e6a Internal - Small change to the new order() method to remove redundant code 2013-04-20 12:04:18 +01:00
Allan Jardine
2e278b0285 New: Ordering functions for the new API:
- order() and order.listener() added (to replace fnSort and
  fnSortListener) from the old API.

- Note that the name `order` is selected to not conflict with the `sort`
  method of the API object, which can be used to order the sort data
  held in the collection.

- The `sort()` method is expanded over the abilities of fnSort to allow
  multiple different forms of input (column + direction, 1D array, list
  of 1D arrays or a 2D array).
2013-04-20 12:00:16 +01:00
Allan Jardine
aa76a6baf5 New: Add ability to do a static redraw to the new API
- draw() and ajax.reload() can now have `false` passed as their first
  (and currently only) parameter, which instructs DataTables to do a
  'static' redraw (i.e. not to reset the pagination).
2013-04-20 11:12:08 +01:00
Allan Jardine
edfbf7491d Internal - altering how a draw is called
- Previously the master sort and filter functions would perform a draw,
  but this was a bit redundant, complex and didn't allow multiple
  changes to be queued up before a new draw was performed. The new API
  will allow this ability, so we need to allow it in the core as well.
  You can now do a sort, and it will be performed internally, but not
  actually drawn until the redraw function is called. This makes a full
  redraw much simpiler, and has the benefit that a standing redraw is
  now relatively trivial since it is all performed in a single place.
2013-04-20 10:18:52 +01:00
Allan Jardine
e014d9272f New: ajax API methods:
- Introducing several methods which will control the ajax aspects of
  DataTables through the API:

  - ajax.json() - get the last JSON returned from the server
  - ajax.reload() - reload from JSON source
  - ajax.url( [url] ) - get / set the Ajax URL
  - ajax.url( url ).load() - load data from new URL after a set

- Note that this effectively replaces the old fnReloadAjax plug-in which
  was quite popular.

- Not yet fully tested - further work required.
2013-04-20 09:10:46 +01:00
Allan Jardine
15588d9e41 New - api methods: page(), page.info(), page.len(), draw()
- Paging control methods for the new API:
  - page() / page(n) - Get / set the current page
  - page.info() - Get information about the table's paging state
  - page.len() / page.len(n) - Get / set the page length

- Rewrite of core.page.js and core.length.js to be more space efficient.
  The functionality is identical to before, but now compresses much
  better (796 byte saving). The new paging API methods add only 614
  bytes (compressed), so overall a saving of 182 bytes, with the new
  functionality added by the new API.

- Start of draw methods for new API:
  - draw() - Draw the table. Need this to test the new paging methods
    since page() etc do not do a redraw themselves, you must call draw()
    when you are ready for the table to be redrawn now.
2013-04-18 07:49:38 +01:00
Allan Jardine
fa7122392d New: tables() and tables().nodes() methods for the new API:
- tables() is a table selector and iterator that most other API methods
  will likely use.

- tables().nodes() gets the selected HTML table nodes.

- Documentation of these functions is rather incomplete. Not yet sure
  how to fully document them. Currently thinking of having seperate
  documentation, a bit like jQuery, which can be a lot more involved,
  rather than building it fromt he doc comments which might get rather
  long (they already are!).
2013-04-17 14:35:15 +01:00
Allan Jardine
e9176bee48 New: First commit for the new Api.
- This commit introduces the new Api core, a 'class' which is a data
  helper and DataTable control interface. Methods of this class are
  designed to be chainable (although it is not manditory - some can
  return boolean values if needed).

- The core data helper functions are present in this comment, although
  not yet fully documented. That will come as the Api stablises and I'm
  happy with the structure.

- There are no table control methods yet - coming soon.
2013-04-16 16:38:53 +01:00
Allan Jardine
b1d88c1c91 Performance: Read the style.width property for the restore width and
apply that.

- This is much faster than the previous method of using $(this).width()
  since there is no longer an invalidation and getComputedStyle
  calculation. It just uses the value that is available in style.width,
  which might very well be empty (if the style attribute is used with a
  width property defined is it not empty).

- This also improves accuracy since it is the original that is restored,
  and not the calculated size.

- See http://datatables.net/forums/discussion/14811 for the discussion
  for this change.

- Thanks to `krzycho` for the discussion and suggestions.
2013-04-06 09:44:52 +01:00
Allan Jardine
ad0e08585f Performance: Width of scrollbars isn't going to change on a single page
between table's being reinitialised, so calculating the scrollbar width
every time is a real hit on performance since it needs to manipulate the
DOM. This change ensures that the calculation is performed only once.
2013-04-06 09:36:44 +01:00
Allan Jardine
182998a7c5 Fix: Remove pointer cursor from cells which cannot be sorted - 14826 2013-03-29 07:27:47 +00:00
Allan Jardine
5a0c1f5ac6 Fix #168 - fnInitComplete should give json as second parameter as well
- When server-side processing is enabled, fnInitComplete will now be
  passed a second parameter, the json returned from the server for that
  first draw, matching the Ajax data source with client-side processing
  option.
2013-03-27 09:25:55 +00:00
Allan Jardine
baa16632ec New - licensing: DataTables is now available under the MIT license
- Full license available here: http://datatables.net/license_mit

- Note that this effectively makes the BSD and GPLv2 licenses that
  DataTables is also available under redundant since the MIT is the most
  relaxed of these licenses. At some point in the not too distant
  future, it would make sense to remove these two licenses and have
  DataTables available under only the MIT license.
2013-03-15 09:56:27 +00:00
Allan Jardine
8d9e620ef2 Merge pull request #160 from zeitiger/master
Refactor filter search from input[text] to input[search]
2013-03-04 02:42:57 -08:00
David Steinkopff
c2dd657fa8 remove hacking 2013-03-04 08:43:11 +01:00
David Steinkopff
8efdd92a46 Merge branch 'master' of https://github.com/zeitiger/DataTables
Add requested changes
2013-03-04 08:38:31 +01:00
Allan Jardine
b87187fc5b Fix #162 - Flexible width is width="100%" is applied as attribute to the HTML table
- Attach an event handler to the window to resize the table. Note that
  this isn't debounced - possibly it should be in future(?), but don't
  want to add the additional code required if it isn't required. It
  seems to function perfectly well for me!

- Unbind needs to unbind by the instance unique reference since there
  might be multiple tables listening for the event.
2013-03-03 12:03:44 +00:00
Allan Jardine
25eaa86477 Dev fix: Typo in the name of _hungarianMap private parameter 2013-03-03 08:36:58 +00:00