Comments (3)
I tomfumb, I'm sorry to only answer you now but I've been away for a while. I am sorry but I will not be able to fix the issue you are facing, simply because it would require a lot of modification for something quite unusual. You should not use HTML elements to store metadata about your rows: You could use the data
attribute of your th
elements to store such information, or even better use the datatable
plugin to internally store these informations and only display what you want.
from datatable.
I agree that the data attribute can be useful but in my scenario this was not possible. A server-side script was generating the HTML through a repeating row template and hidden table columns was the only way I had to communicate metadata.
Regardless of the reason I think it's sensible for javascript libraries to respect DOM display properties, or at least provide that as a non-default option, to adhere to the 'principle of least astonishment'. Thanks for your hard work providing Open Source tools to strangers!
from datatable.
Even if I think this is not useful anymore for you, I will put some useful stuff here (and close this issue).
After some tries, I didn't manage to easily solve this issue. Because of the ways filtering and sorting work, it would require a lot of works to ยซ respect ยป hidden columns.
However, there is a very simple way to deal with hidden columns, but which required a few steps from you (or anyone using the plugins). Assuming you have 3 columns, and the second one is hidden, you could do the following (the important options are sort
, filters
and lineFormat
):
$('#mydatatable').datatable({
sort: {
0: true,
2: true
},
filters: {
0: true,
2: 'select'
},
lineFormat: function (id, data) {
var tr = $('<tr></tr>') ;
tr.append('<td>' + data[0] + '</td>') ;
tr.append('<td style="display: none">' +
tr.append('<td>' + data[2] + '</td>') ;
return tr ;
}
}) ;
The key here is to:
- Use objects instead of arrays from
sort
andfilters
options, so you can specify only the columns you want (0 and 2 here). - Use a custom
lineFormat
to display hidden columns.
from datatable.
Related Issues (20)
- 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
- how to set default page ? HOT 1
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.