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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top