开发者

href cell in a data grid Dojo

开发者 https://www.devze.com 2023-03-23 00:46 出处:网络
i cant find how put a cell with an href in a dojo 开发者_运维技巧toolkit datagrid, the version od dojothat am using is 1.6

i cant find how put a cell with an href in a dojo 开发者_运维技巧toolkit datagrid, the version od dojo that am using is 1.6 this is my table

  <table id="billsGrid" dojoType="dojox.grid.DataGrid" data-dojo-props="escapeHTMLInData:false">
        <thead>
            <tr>
                <th field="name" width="auto">name</th>
                <th field="description" width="auto">Description</th>
                <th field="activity" width="auto">activity</th>
            </tr>
        </thead>
    </table>

am getting the data with Json.


You can use formatter function to format a cell. For example, you can declare a JavaScript object that contains all the formatting function.

var myFormatters = {
   formatLink : function(value, index) {
        return "<a href='#'>" + value + "</a>";
   }
};

Then in the grid,

<table id="billsGrid" dojoType="dojox.grid.DataGrid" data-dojo-props="escapeHTMLInData:false" formatterScope="myFormatters"  >
    <thead>
        <tr>
            <th formatter="formatLink" field="name" width="auto">name</th>
            <th field="description" width="auto">Description</th>
            <th field="activity" width="auto">activity</th>
        </tr>
    </thead>
</table>

You don't need to create a scope object for the formatters, then this formatting functions should be in the global scope and then you can omit the formatterScope attribute in the grid.


dojo grid is escaping html tags by default for security reasons, you can simply enable html tags doing this:

<table dojoType="dojox.grid.DataGrid" escapeHTMLInData="false" ...>

or this if your grid is added programatically

escapeHTMLInData: false

more info here: http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html

0

精彩评论

暂无评论...
验证码 换一张
取 消