2015-07-04 22 views
0

我想在Dojo Grid中添加下載鏈接。任何一個可以提供我的方式來產生鏈接在JSON如何在Dojo Grid中添加下載鏈接

佈局 變種佈局= [{ 字段: 'ID', 名: 'ID', 寬度: '100px的' }, { 字段: '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)); 

回答

1

如果你問如何把一個鏈接在dgrid單元格,然後你需要重寫列的renderCell功能。

例如

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; 
      } 
     } 
    }, 

這裏有一個jsfiddle of an anchor/link in a dgrid cell.

+1

我猜問題是關於基於問題的佈局'DojoX中/ grid',但它會一直有益的,如果問題是關於更清晰:) –