I can't create table with datas. maybe someone will help me?
I can't create table with datas. maybe someone will help me?
shahen
Posts: 18Questions: 2Answers: 0
This is my code.
table = $('#entries').DataTable({
lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
data: data_table,
aoColumnDefs: [{ aTargets: -1, bSortable: false, bSearchable: true }],
"aaSorting": [[0,'desc']],
columns: data_columns,
'createdRow': function( row, data ) {
$(row).attr('rowid', data["rowid"]);
$(row).attr('subid', data["subid"]);
}
});
where
data_table = {browser:"Chrome",confirmed:"<i class="hi-icon hi-icon-small icon-not-confirmed" title="Not confirmed yet">0</i>",
country:"Armenia",
date:"<span>2018-02-13</span><br><span>11:39:24</span>",
field1:"hjkh ityui",
field2:"tryjtyu@dfg.df",
field3:"fghryjrtt yryj rtukr ttyeu r",
os:"Windows 7",
rowid:0,
subid:4904559 };
and this is
data_columns =0:{data: "date", title: " Entry Date", mData: "date", sTitle: " Entry Date"}
1:{data: "field1", title: "Name", mData: "field1", sTitle: "Name"}
2:{data: "field2", title: "Email", mData: "field2", sTitle: "Email"}
3:{data: "field3", title: "Your Comments", mData: "field3", sTitle: "Your Comments"}
4:{data: "browser", title: "User's Browser", mData: "browser", sTitle: "User's Browser"}
5:{data: "os", title: "User's OS", mData: "os", sTitle: "User's OS"}
6:{data: "country", title: "User's Country", mData: "country", sTitle: "User's Country"}
7:{data: "confirmed", title: "Confirmed", className: "columnCenter", mData: "confirmed", sTitle: "Confirmed", …}
8:{data: "subid", title: "Submission ID", mData: "subid", sTitle: "Submission ID"};
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
it gives an error "jquery.dataTables.js:58 Uncaught TypeError: Cannot read property 'style' of undefined"
Hi Shahen
The data that you're trying to display (data_table) doesn't match the structure you've defined (data_columns). Plus, data_table doesn't look like a table of data!
Take a look at this example, it should get you going in the right direction.
Cheers,
Colin
Hi Colin. I am going to learn that exmaple. But when I delete 1 or 2 of data_columns it works perfect))).
No this example didn't help me.
Hopefully this live example will
There's many problems with that initial code above and the organisation of the data. It's probably best to compare the two side by side and see what changes need to be applied.
Cheers,
Colin
Thank You
Colin my code works perfect in live example. But on site it again shows error Cannot read property 'style' of undefined"!! I read about it. The problem is that the number of <th> tags need to match the number of columns in the configuration. but it doesn't. Why?
What I have to do?
This Stackoverflow chat may help with that:
https://stackoverflow.com/questions/42368773/cannot-read-property-style-of-undefined-uncaught-type-error
Beyond that, we'd really need a link to a page showing the issue so we can debug it.
Allan
I have written the url Allan. I really tried everything))))
I don't see a link to your page demonstrating the issue here. Please post it again.
I got that messege - Your comment will appear after it is approved
This
I don't actually see it in the spam queue which is odd. I got your PM though. It don't see the error happening on that page.
Allan
I fixed the error. I don't know what is the problem, but I deleted all code, and started again. It's possible I had done an idiotic mistake, know everything is ok. Thank you. You are the best support team