Comments (6)
I don't really understand what you want to do... You would like to be able to sort specific columns without having to specify true
/false
for all the others?
from datatable.
Hi Mikaël
I'm obviously not making the idea clear.
At the moment config.sort tends to be like [true, false, true, true etc..]
This does not help with tables like this
<tr>
<th>stallion</th>
<th>runners</th>
<th colspan="2">winners</th>
<th>w/r</th>
<th>starts</th>
<th>wins</th>
<th colspan="2">stakes </th>
<th colspan="2">progeny earnings</th>
</tr>
with complex strings like £1,500,000 in the sort columns for progeny earnings which need to be sorted out by a function.
What I was suggesting is the ability to put an integer in the column position to indicate a sort column, not just true, and also the capability of and integer and a function for processing the data to make it sortable.
config.sort = [false, true, true, 4, false, false, false, {column: 9, func: price_sort,}];
would make 'w/r' sort on column 4 and 'progeny earnings' would sort on column 9 using the function price_sort to implement the sorting function for data like £1,500,000
Hope that is clearer.
Jules
from datatable.
@julesbl I have to admit that I am not even sure of all the features available in this plugin anymore (the documentation is way outdated... ), but I think that what you want is already implemented in the following way:
config.sort = {
0: false,
1: true,
2: true,
4: true,
5: false,
6: false,
9: number_sort
};
from datatable.
Works very well when there are the same number of header columns as data columns, where it comes unstuck at the moment is when they differ, as in this case 8 header cols and 11 data columns, there is no way to tell the sort function to work on anything but column 7
from datatable.
@julesbl The index/keys of the array/object you use for the sort
options are match with the <th>
elements (the nth element of config.sort
will be used for the nth <th>
). If either:
- the number of
<th>
does not match the number of columns; - the
<th>
have different index than columns;
...you can use an Object
instead of an Array
, such as the one in my previous answer, to specify on which column each <th>
should sort.
Small example:
If your <th>
are like this:
<tr>
<th>TH 1</th>
<th colspan="2">TH 2</th>
<th>TH 3</th>
<th colspan="2">TH 4</th>
</tr>
Then:
[true, true, true, true];
...will make TH 1
sort the first column, TH 2
the second, TH 3
the third, and so on...
But:
{
0: true,
1: true,
3: true,
4: true
}
...will make TH 1
sort the first, TH 2
sort the second, TH 3
sort the fourth and TH 4
the fifth.
from datatable.
Thanks, had not twigged about the object
from datatable.
Related Issues (20)
- IE 11: Pagination and filter not working correctly HOT 2
- Inject data to table row HOT 4
- Nullpointer Exception table with filter and no data
- Not working on my project :( HOT 6
- CSS not work HOT 4
- Extract filtered records HOT 11
- Filter outside the table HOT 2
- No idea how to make filter outside table HOT 1
- Get number of a table row. HOT 6
- Update table data HOT 19
- Process Ajax Data Before Displaying on Table! HOT 3
- Using Filter/Sort with hidden child rows HOT 3
- Question: How to search/filter multiple columns with one search field HOT 2
- Was cleared all attributes from td. HOT 1
- Click in a row event HOT 3
- Filter by date mm/dd/yyyy HOT 1
- Ajax Doesn't Work HOT 4
- filter is not function after apply addRows HOT 2
- Table reload method HOT 2
- how can i implement for rowspan ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatable.