Download link

Download link

mariyanandhmariyanandh Posts: 4Questions: 0Answers: 0
edited July 2011 in General
I am using server side processing, I need one column with image indicating downloadable, once the link is selected, I want to make to process download.

How to implement this? please help me.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    How would you do it without DataTables? I think the same process would apply. Typically you would just have a link to a script which will generate the download for you.

    Allan
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited July 2011
    I've done something similar to this, with a "delete row" image/link, using fnRender.

    in my db call, I create an extra column (any field will do, I use the ID field a second time) and for that column use fnRender to create the link using an image.

    [code]
    "aoColumns": [
    // ... some other columns first
    {
    "sName": "id",
    "sWidth": 30,
    fnRender: function(oObj) {
    var id = oObj.aData[0];

    return "";
    },
    "bSortable": false,
    "bSearchable": false
    },
    // ... some other columns after
    [/code]

    fnRender passes one arg: oObj, which has goodies like the row number, column number, and an array of the entire row's data. (see http://www.datatables.net/ref) in my case, I'm deleting based on the ID, which is in position 0 in the data array.

    Your function must return a string; this becomes the HTML of your cell.

    qapub_delete.php is my deletion script on server side. in your case, the href will be whatever download resource you intend. graphics/delete.png is my image.

    oObj has these parts:
    - int:iDataRow - the row in aoData
    - int:iDataColumn - the column in question
    - array:aData - the data for the row in question
    - object:oSettings - the settings object for this DataTables instance
  • mariyanandhmariyanandh Posts: 4Questions: 0Answers: 0
    thank you . its working
This discussion has been closed.