my csv button is missing please advice

my csv button is missing please advice

Answers

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    Take a look at the browser's console and you will see this error:

    jquery-3.1.0.min.js:2 Uncaught ReferenceError: url is not defined

    The problem is url is not defined for your columns.render function:

                    "render": function(data, type, row) {
                        return url + '?params=' + row[0] + "'>" + row[0] + "</a>";
                    },
    

    I defined the url variable in this updated test case and now the CSV button appears:
    http://live.datatables.net/nixujuko/2/edit

    Kevin

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 0

    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.

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 0

    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

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    i see 4-5 times row[0] is printed through columnDefs rendering function. why?

    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

    And also when I click on CSV button it goes to columDefs rendering function too.

    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.

    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>

    This is the result I see from your test case:

    "Name","Position","Office","Age","Start date","Salary"
    "unit","System Architect","Edinburgh","61","2011/04/25","$3,120"
    

    Is the test case result different from your deployed solution?

    Kevin

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 0

    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"

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    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?

    <a href='ds.html?params=<a href='ds.html?params=unit'>unit</a>'>unit</a>
    

    The test case has a had coded url variable. Have you verified it is correct and the same as the test case?

    Kevin

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 0

    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].

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 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];
    }

  • umaeswaraumaeswara Posts: 69Questions: 13Answers: 0

    Hi Kevin, do you see any issue in my fix or is it ok do that.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

Sign In or Register to comment.