my csv button is missing please advice
my csv button is missing please advice
umaeswara
Posts: 72Questions: 14Answers: 0
in DataTables
Answers
Take a look at the browser's console and you will see this error:
The problem is
url
is not defined for yourcolumns.render
function:I defined the
url
variable in this updated test case and now the CSV button appears:http://live.datatables.net/nixujuko/2/edit
Kevin
thanks for the quick reply and correction. actully i wanted to ask a question and when created testcase, forgot to add url variable. my original question was pertaining to the columnDef rendering function. when I see in the console
http://live.datatables.net/toxanume/1/edit
i see 4-5 times row[0] is printed through columnDefs rendering function. why? there is only one row.
And also when I click on CSV button it goes to columDefs rendering function too. in my workplace code, what is happening is when I click on CSV it is rendering again and my url link is becoming like this
<a href='ds.html?params=<a href='ds.html?params=unit'>unit</a>'>unit</a>
and thus in the csv file it is cell value is coming as
unit'>unit
instead of
unit
Datatables is executing the render function for the different orthogonal types. I updated the test case to show this:
http://live.datatables.net/toxanume/2/edit
I suspect this is so Datatables can export the data as displayed instead of the raw data. Note that you can define orthogonal data for the export as shown in this example.
This is the result I see from your test case:
Is the test case result different from your deployed solution?
Kevin
yes, in my deployed version my csv file has
"Name","Position","Office","Age","Start date","Salary"
unit'>unit,"System Architect","Edinburgh","61","2011/04/25","$3,120"
Its hard to say without seeing the problem.. The same
display
render is run for the table display and for the csv export so they should look the same. Have you inspected the web page to make sure the cells have the correct format and not something like this?The test case has a had coded
url
variable. Have you verified it is correct and the same as the test case?Kevin
Hi Kevin, thanks for looking into this. what I observe is when click on csv and it goes to columnDefs render function row[0] already has <a href='ds.html?params=unit'>unit</a> that is why when it is rendering it is again doing url + '?params=' + row[0] + "'>" + row[0] + "</a>" step and adding one more <a href..... on top of already existing a href link.
yes, i cannot reproduce that issue in my testcase here. but in deployed place it is showing that it is happening twice and thus making row[0] .
I tried to do
if (!row[0].match('href')) {
return url + '?params=' + row[0] + "'>" + row[0] + "</a>";
}
but then I am getting an error message that DataTable error asking unknown parameter 0 for row 0 and column 0 .
and csv file has an empty cell for tow[0].
Hi Kevin,
I am able to solve the problem with this small change. see
if (!row[0].match('href')) {
return url + '?params=' + row[0] + "'>" + row[0] + "</a>";
} else {
return row[0];
}
Hi Kevin, do you see any issue in my fix or is it ok do that.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin