Dilip Godhani
Dilip Godhani

Reputation: 2174

How can i put a download Link in Dojo Grid

I want to put a download link inside Dojo grid . can any one provide me way to generating link in json

Layout var layout = [{ field: 'id', name: 'id', width: '100px' }, { field: 'Download', name: 'Download', width: '100px' }];

Java code for generation Json 

    JSONObject json = new JSONObject();
        json.put("Id", "1");
        json.put("ProductName", "Download Link");
        JSONArray  finalArray = new JSONArray();
        finalArray.add(json);

        setResponse(getTopLevelJsonObject(finalArray).serialize(true));

Upvotes: 0

Views: 183

Answers (1)

inanutshellus
inanutshellus

Reputation: 10001

If you're asking how to put a link in a dgrid cell, then you need to override the column's renderCell function.

e.g.

    columns: {
        id: {label:'ID'},
        name: {
            label:'Name',
            renderCell: function(object, value, node, options) {
                var anchor = domConstruct.create("a");
                anchor.href = "http://www.google.com";
                anchor.innerHTML = value;
                return anchor;
            }
        }
    },

Here's a jsfiddle of an anchor/link in a dgrid cell.

Upvotes: 1

Related Questions