Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column mData defined as a function not working #95

Closed
stt opened this issue Oct 20, 2014 · 7 comments
Closed

Column mData defined as a function not working #95

stt opened this issue Oct 20, 2014 · 7 comments
Labels

Comments

@stt
Copy link

stt commented Oct 20, 2014

With DataTables 1.10.3 and yadcf 0.8.4 when specifying datatable column's mData (or data) as a function, yadcf's appendFilters function throws an exception when it ends up trying to do split() on the function object here

A simple js that reproduces the issue:

$('#example').dataTable({
  data: [{}],
  columns: [
    {
     mData: function() { return "blah"; }
    }
  ]
})
.yadcf([
  {column_number : 0},
  ]
);

I'm not sure why the _aFilterData check is in it's own if-block so don't know if this introduces something new in another situation, but changing the code as follows fixes it for me:

            if (column_number_data === undefined) {
              col_inner_data = data[j]._aData[column_number];
            } else if (data[j]._aFilterData !== undefined && data[j]._aFilterData !== null) {
              col_inner_data = data[j]._aFilterData[column_number];
            } else {
              col_inner_data = dot2obj(data[j]._aData, column_number_data);
            }
@vedmack
Copy link
Owner

vedmack commented Oct 21, 2014

Thanks for the very detailed issue, gonna check/fix as soon as I can

@vedmack vedmack added the bug label Oct 21, 2014
vedmack added a commit that referenced this issue Oct 25, 2014
columns -> "mData": function() support #95

custom_func support in exGetColumnFilterVal
#93
@vedmack
Copy link
Owner

vedmack commented Oct 25, 2014

fixed in 0.8.5.beta.5, thanks

@SergioV85
Copy link

Hi! I've got similar problem on 0.8.9 version with latest DataTables 1.10.

I have next code

var table= $('#searchTable');
var tableSettings = [{
    "data": function (row) {
        var devId = row._source.hasOwnProperty('id') ? row._source.id : '';
        return '<a href=#>' + devId + '</a>';
    }
}];
dTable = table.DataTable({
    data: results,
    "columns": tableSettings
})
yadcf.init(dTable, [{ column_number: 0, filter_type: "text", column_data_type: "html", html_data_type: "text" }]);

result is JSON object, received from elasticsearch.
But, every time I receive next error:
dot_refs.split is not a function
When I tried to debug, I found that in function dot2obj(tmpObj, dot_refs) variable dot_refs is a function from tableSettings, and this is reason, why it can't be splitted

@vedmack
Copy link
Owner

vedmack commented May 25, 2016

Hi,

Please provide a jsbin sample to speed up the fix for this one.

@SergioV85
Copy link

Hi!
Here jsbin example

@SergioV85
Copy link

Hi! Any news?

@vedmack vedmack reopened this May 30, 2016
@vedmack
Copy link
Owner

vedmack commented May 31, 2016

Ohhh.....

You must remove the "searching": false, because when it is set to false no filtering will be possible in datatables at all, in addition you should change from

column_data_type: "html", 
html_data_type: "text"

into

column_data_type: "rendered_html"

read docs about it...

p.s

see working sample

@vedmack vedmack closed this as completed May 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants