Column Orthogonal Data not working properly
Column Orthogonal Data not working properly
agreenspan
Posts: 11Questions: 3Answers: 0
I think there is a bug with orthogonal data. Column 8 simply will not work.
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var selected_states = []
$("#collection_filters :checkbox" ).map(function() {
if ($("#"+this.id).is(":checked")) {
selected_states.push(this.id);
}
});
var states = [data[5], data[6], data[7], data[8], data[9], data[10] ];
console.log(states);
if (selected_states.length == 0) {
return true;
}
else {
found = false;
$.each(states, function( index, value) {
if (($.inArray(value, selected_states))!==-1) {
found = true;
}
});
if (found == true) { return true; } else { return false; }
}
}
);
data[8] on one page and data[9] on another (from the same view!) are not pulling the value from data-search. they are instead pulling the display data. columns 5-10 are all generated from a loop and are identical.
<% collection[:planars].select {|i| i.id == planar.id }.each do |collection| %>
<% collection.attributes.each do |key, value| %>
<% if key != "id" %>
<td data-search="<%= (value > 0 ? key : '') %>">
<%= ( value > 0 ? value : "" ) %>
</td>
<% end %>
<% end %>
<% end %>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Spoke too soon. still broken.
Can you please link to a test case, as required in the forum rules.
The documentation notes that the second parameter is an array of search rendered data and the fourth is the raw data.
Allan
Sorry about that. This is a development server currently and not on the web. Let me put it up and create a login for you to test with.
http://drawdiscard.com:3000/ARB
un: test@test.com pw: testtest
I think its the same issue as:
https://github.com/rweng/jquery-datatables-rails/issues/102
My data-search looks like this:
So i think some columns might be blank in the first row. I'm using a placeholder ` for now as a workaround.
Try to use the collection checkboxes. I've removed my workaround so you can see the behavior. Check the console log. I'll put data in there.
Hi,
Thanks for putting the page up. Could you confirm the actions I need to take on the page to see the issue, what is actually happening and what should be happening?
At the moment when I click the checkboxes down the side, the table appears to be filtered as expected.
Thanks,
Allan
Try clicking the blue DD circle filter on http://drawdiscard.com:3000/BNG.
Rebuilding the DB. Site will be down for a while.
http://drawdiscard.com:3000/THS
Log in with the test account.
Expand the collection filters.
Click the selling (For Sale icon) filter.
Great - thanks for the update. Allowed me to find and fix the issue! This was (sad to say, but so it goes...) a bug in DataTables. If the attribute in the first row in the table contains an empty string, then it was failing to use the rest of the attributes for that column.
I've just committed a fix and the nightly version will be up-to-date with the change very shortly.
Thanks for your help with tracking this down!
Allan
Thanks Allan! For now, I'm going to put my workaround back in place until the next stable DataTables version is released and the ruby gem gets updated. Nice to know I wasn't going crazy.
Can you explain your fix btw? Just so I get a better understanding of what was breaking and how it works now?
Certainly - the problem was that the condition I had was checking for all "falsy" values (null, empty string, 0, undefined). Any of them would have triggered the issue. So when
getAttribute
returned an empty string, the condition failed and DataTables "thought" (it isn't sentient yet!) that there was no data attribute for that column.The fix is to check for a
null
return, which isgetAttribute
's way of saying that the attribute doesn't exist on that node.Allan