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

76 Commits

Author SHA1 Message Date
Allan Jardine
6b605936f7 Update: Significant update to how sorting is applied internally in DataTables - there is no difference to how the sort is actually done, with the single exception that the -asc and -desc are not depricated in favour of the -pre method only.
- With the introduction of the -pre method in DataTables 1.9, the -asc and -desc sorting functions became more or less redundant since they are simple comparisons (all of the complexity is now in the -pre formatting function). As such the call to the -asc / -desc method is overhead that really isn't needed, and this commit introduces a sort function that doesn't call the -asc / -desc methods, instead just doing the comparison itself. In tests, this relatively simple change leads to a performance improvement of around 15% in all browsers (it also has the side benefit of less operations, so IE8- will be able to sort larger tables before flagging up a slow script warning).

- We can't just remove the sorting method which will call -asc / -desc though since not all sorting plug-ins will have a -pre method. Therefore, for backwards compatiblity the old sort function (albeit updated for the changed variables) is retained. The backwards compatibality code adds around 300 bytes to the library, but this is an unaccounced change, so backwards compatiblity must be retained.

- The old sort method will be removed in v1.11. The -asc and -desc methods are now fully depricated.

- Altered the sorting method to flatten the aaSorting array since the introduction of aDataSort in v1.9 required an extra loop in several locations. The functionality is very useful, but the extra loop can be a bit messy and slightly hit performance, so it is now flattened to be a single array (with object information so it makes sense, rather htan array indexes!).

- Altered the order of sorting when building _aSortData since it was looking up the same variable smultiple times which really wasn't needed.

This is part of a small incremental changes plan for DataTables! There are still a huge number of things to improve in this area, but this is a nice clean up and a nice 15% sorting performance improvement to get us started :-).
2012-09-29 21:25:41 +01:00
Allan Jardine
1f0b162760 Dev fix: In the update to the search array building methods I neglegted to strip \n\r from all rows (only HMTL rows were being stripped) - this is required for searching to work as expected. Picked up by the unit tests. 2012-08-08 22:05:14 +01:00
Allan Jardine
fd0e0a42e4 Fix #39 - null values should also be considered like undefined values when working with nested data and have properties created as needed. 2012-08-08 20:16:40 +01:00
Allan Jardine
0804c50d72 Dev: Unit tests for set functions 2012-08-08 20:02:59 +01:00
Allan Jardine
f03c670cf9 Update: Unit test updated for the mData name change from mDataProp. Note that a number of tests to test the backwards compability of mDataProp! 2012-06-29 20:10:15 +01:00
Allan Jardine
0ed6ceda95 Updated: mDataProp syntax now has the ability to accept array syntax (for example "access[].name" would get an array of the 'name' properties from the access property of the data source). This is exceptionally useful for manipulating arrays - however, you are very _strongly_ advised not to use in in mDataProp itself, since when setting arrays, you will overwrite the old array (thus destroying any other properties that it already has!). Instead, see the new mRender property if you want to make use of this syntax for drawing the table. 2012-06-29 17:47:00 +01:00
Allan Jardine
827d4c1ae4 Fix unit tests: Witht he change to allow info macros in any of the strings the unit tests need updating to reflect this 2012-04-13 18:23:43 +01:00
Allan Jardine
aef0be6a1d Fix unit test: Number of errors in this test 2012-04-13 18:23:19 +01:00
Allan Jardine
e290b2cd7a Fix - unit test: Async behaviour could cause test to fail since the init might not have been complete (amazing that it was passing all this time - faster computers and faster JS engines now causing it to fail!) 2012-04-13 18:22:18 +01:00
Allan Jardine
409edd791b Fix: When sorting non-string data as a string (type to type detection) then DataTables 1.9 would automatically convert the non-string data to an empty string so it can be sorted. This can result in unexpected ordering in the table. The fix is to check for a toString() function that is available for the data and if it is there, then use it (great for numeric data, dates etc), otherwise the empty string is used (null, methods without toString). This brings 1.9 back into line with how 1.8 behaved - 8549 2012-02-17 09:29:41 +00:00
Allan Jardine
ab9dfd5052 Fix: x-scrolling to the end of a table would cause the header and the columns to go out of alignment due to the header not being able to scroll as far as was needed (this was caused by the changes in 876a75f) - 8332.
Fix: Table could conitnually expand when x-scrolling was enabled. This was partly addressed in 6776, but the fix was incomplete as it would still occur on Safari Mac (possibly other browsers as well). This fix is very closely related to 8332 (hence commiting together as they are interdependent). Now use padding right on the header/footer wrapper to provide the overflow scroll ability, but only add it when a scrollbar is present - otherwise the width gets added on and we get the forever expanding table.
Dev: Unit tests - New tests for scrolling to ensure 6776 and 8332 don't occur again
2012-02-06 18:09:16 +00:00
Allan Jardine
468390c337 Fix: When mDataProp was used to get a nested object, but a parent object didn't exist it would throw an unrecoverable error. With this change the behaviour matches that of single level data whereby if data cannot be found, at any level, then undefined is returned from the data get object. This means that if sDefaultContent is defined then that will be used instead, and if not defined an error will still be given (although this one under DataTables' control).
Dev: Removed the "fast lookup" function for data get and set as they weren't really that useful in terms of speed and would require more code to be added to copy with the above change to the error handling for missing objects. Smaller code and virtually no difference in speed. Sold.
2012-02-01 08:16:49 +00:00
Allan Jardine
cb014e81d7 New: Add unit tests for fnCreatedCell and fnCreatedRow
New: New init option fnCreatedRow - very similar to fnCreatedCell but in this case used for TR elements
Updated: fnCreatedCell now also gets the column index passed in
2011-12-28 11:12:30 +00:00
Allan Jardine
4808f0edd7 Dev update: Remove the 'row' event. On experimenting with CellCreated I've found that I'm getting around 4'500 triggers / sec with Safari 5.1, which really isn't close to fast enough (about two orders of magnitude out from what I would like) which means that a table with 2000 rows and 9 columns would see an additional overhead of about 4 seconds on initialisation - ouch!!! As such I've removed the 'row' event here and it would seriously impact larger tables. events are still extremely useful, however, I would suggest that plug-ins should use the callback arrays rather than events since it is much faster. These arrays might be developed further into DataTables' own triggering methods in future. Something to to be aware of certainly going into 1.10. 2011-12-27 19:46:43 +00:00
Allan Jardine
dae243eb7a Fix: fnRender unit tests need to be updated for the change to the second argument being passed 2011-12-27 13:54:22 +00:00
Allan Jardine
27488c4093 Tidy up use of typeof and undefined in DataTables - the main goal is to reduce code size under 70K here, but its a good opertunity to get this area sorted out. Note that the unit test update for fnInitComplete is because 'json' is now always passed through, although it will be undefined in anything but Ajax sourced client-side processing. 2011-12-14 13:35:49 +00:00
Allan Jardine
f535031e41 New: Use localeCompare to do string comparison, allowing much better internationlisation support for sorting strings in DataTables 2011-12-07 11:07:02 +00:00
Allan Jardine
7d2d62d519 Update unit tests to take account of the change to the pagination elements now being A tags, rather than SPANs/DIVs. Good that the change broke the unit tests since it is backwards incompatible 2011-12-06 16:18:50 +00:00
Allan Jardine
25fadbc644 Add unit test for filtering on non-string input 2011-12-06 10:39:08 +00:00
Allan Jardine
6c923e4953 Performance changing sorting / filtering 2011-12-06 10:38:23 +00:00
Allan Jardine
6610ec24b8 Unit tests were using asStripClasses which was an old legacy typo... It should be asStripeClasses and I've removed the alias in 1.9, thus the unit tests need to be updated. 2011-12-04 18:11:36 +00:00
Allan Jardine
e1fb1748a8 Add a default unit test set for the mDataProp test set - objects 2011-12-03 09:57:09 +00:00
Morten Brix Pedersen
5732f4c1fa Fix typo 'destory' -> 'destroy'. 2011-11-07 09:55:01 +01:00
Allan Jardine
c655c92cfe Fix: Unit test compatibility fix for IE7 2011-09-10 10:35:03 +01:00
Allan Jardine
5131e1dd7f Fix: HTML column type could sometimes be overridden by the string sorting type. If a cell was found to have just a string and no HTML in it then the whole column would be treated as a string column, even if other cells had HTML. Now put a check in place to ensure that string can't overrule html type. Unit test added. 2011-09-09 19:32:59 +01:00
Allan Jardine
2c9ce2aa59 Fix: When filtering is applied to a table which has y-scrolling, and the filter was sufficient to make the scrolling disappear, the table width would increase by the scrollbar width. This was of course incorrect and the result of a change for 1.8.1 - we need to test is the scrollbar is present or not for the fix to be correct, which it now does. Unit test added.
Fix: As with the fix in 1.8.1 for the x-scrolling appearing when disabled the footer needs the same consideration as the header, otherwise it can be cut off visually.
2011-06-29 18:08:14 +01:00
Allan Jardine
56a7564ee8 Dev fix: fnDestry wasn't reapplying original with correctly due to a mistake in an earlier commit - picked up by unit tests 2011-06-25 17:43:47 +01:00
Allan Jardine
aaf9697bd6 Fix: The ability to use complex data structures in 1.8 means that arrays which are passed into to fnUpdate need not strictly be the same length as the number of columns in the table - therefore the warning that is given if you do this is wrong... no other code changes needed - just no need to generate the warning! Unit test added - 5396 2011-06-21 18:38:00 +01:00
Allan Jardine
e08f95f5a2 Update: Unit tests which text the argument count for fnServerData updated to include oSettings being passed as fourth argument
New: sLoadingRecords tests added for Ajax source loading
2011-05-29 19:00:16 +01:00
Allan Jardine
5576cf2097 Dev fix: fnRender is only called once per row now for Ajax sourced data 2011-05-08 18:58:34 +01:00
Allan Jardine
b52665fd6b Fix: Allow non string and numeric data types in the data source (including null and boolean etc). Add suitable unit tests to sanity check this. 2011-05-04 19:21:41 +01:00
Allan Jardine
06d1802874 New: Support TH elements in the table's TBODY. TH elements are now treated just like TDs in the body. This will work only with DOM sourced data out of the box - any body cell elements that DataTables creates are still TD. 2011-05-04 18:30:44 +01:00
Allan Jardine
2c8868dd53 Update version number to 1.8.0.dev.2 for beta 2 development work
Fix: Call fnRender only once when using using bUseRendered (don't need to call it twice since our internal data cache already has the rendered value stored) sin
ce this can cause some confusion with re-writing the data source value - 4871
2011-05-02 22:32:54 +01:00
Allan Jardine
144bd6e178 Dev update: Change the name of the custom data property for Ajax sourced data 2011-04-27 22:05:00 +01:00
Allan Jardine
e9adba0802 Dev change: mDataSource renames to mDataProp. Reason for the change is that in future we could have mSortProp and mFilterProp if we wanted to sort / filter on something other than the main data. Also we are refering to a property of the source object (or an index of the source array - hence keeping the 'm' prefix) 2011-04-23 10:38:00 +01:00
Allan Jardine
d60b9fd923 New: Add deferred loading example 2011-04-23 06:49:34 +01:00
Allan Jardine
503c3cfca5 New: Add unit tests for deferred loading with server-side processing
Remove: Deferred loading for Ajax sourced data - was incomplete and would be messy to fully implement
2011-04-22 23:14:20 +01:00
Allan Jardine
dbc8046e6b New: Creation of TR/TD elements when using an Ajax or JS source for the table can be defered until draw time, when the rows are actually needed now - 4739. This is enabled by setting bDeferRender to true at initialisation time. It provides major benefits for speed in IE when dealing with large tables. However do note that if you are using fnGetNodes() with this enabled, then you will only get nodes which have been rendered.
New: Unit tests for delayed rendering. Now up to 2500+ unit tests :-)
2011-04-22 19:51:06 +01:00
Allan Jardine
2d0aff2b39 New: The ability to customise the property that is read when obtaining Ajax information from the server, for the data to insert into the table. The new initailisation parameter is sAjaxDataProp. It can be used with Ajax sourced data or server-side processing. When Ajax sourced data is used, it can be an empty string in which case it is assumed that an array has been passed into DataTables directly. Note also that it uses the same object data processor as mDataSource, so you can use dot notation to read from nested information (e.g. 'my.data'). 2011-04-21 18:37:36 +01:00
Allan Jardine
349a78dc43 New: Unit tests for mDataSource of various types. Run sanity checks on five possible varations 2011-04-20 20:26:14 +01:00
Allan Jardine
a6c8a13e6a New: Unit tests for column visibility with complex headers and fnSetColumnVis 2011-04-20 20:05:14 +01:00
Allan Jardine
f172ef5383 New: Significant change to how data is handled by DataTables. DataTables now has the ability to deal with complex objects as data sourced, which is particularly useful for dealing with Ajax data, and other data which doesn't belong in the visible table (db IDs for example). See the examples/ajax/ files that are in this commit for examples on how this works. More unit tests and further tidy up to come. Detailed examples will also be added in future - the current examples are mainly for testing 2011-04-19 19:35:33 +01:00
Allan Jardine
6849515c0e Updated: Complex header behaviour has changed slightly to make the bottom unique TH element the one which has the sorting listener attached. Updated unit test 2011-04-12 21:33:47 +01:00
Allan Jardine
bb5bb1c37f Fix: Modify unit tests for all warnings enabled in PHP and remove depricated function calls 2011-03-01 21:45:57 +00:00
Allan Jardine
ede9f77de8 Updated: Reliability of unit tests in non-webkit browsers 2010-12-15 21:22:22 +00:00
Allan Jardine
65b7c9b1e6 Performance: Re-written the sorting implementation so it doesn't use either eval() of $.inArray(). inArray was found to have a serious negative effect on IE which counts operations to give the 'script is running slow' error message - the new implemention uses a value / key reverse mapping to make the look up as fast as a single object parameter retreival. Furthermore, I've done some optimisation and feature completeness work on the non-eval version of the sorting (previously the AIR sorting method) and I've found this to be at least as good (faster in some cases) than the old eval() sort, so this is now the default and only sorting method DataTables provides - 2922 2010-11-28 14:42:38 +00:00
Allan Jardine
d141d8370a Fixed: The behaviour for complex headers has been altered slightly for complex headers in that only the first of non-unique TH elements will be click to sort-able. Unit test update needed as this is different behaviour from before when all elements belonging to a column were click to sort. 2010-11-17 08:25:54 +00:00
Allan Jardine
612070b2d7 Update: Slightly modification to timing for unit tests to be more flexible 2010-10-30 08:01:28 +01:00
Allan Jardine
4e11bf9e9c Fixed: Unit tests could fail due to interaction between state saving cookies. Now when tests which state save end, they must call fnCookieDestroy. 2010-10-17 07:43:17 +01:00
Allan Jardine
a2d7a32b2f Fixed: Sorting disabled classes were not being correctly applied if sorting was disabled. This was particularly obvious with jQuery UI theming - 3064 2010-10-16 10:59:21 +01:00