1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
<?xml version="1.0" encoding="UTF-8" ?>
<dt-option group="columns">
<name>columns.defaultContent</name>
<summary>Set default, static, content for a column</summary>
<since>1.10</since>
<type type="string" />
<description>
Often you may wish to have static content in a column, for example simple edit and / or delete buttons, which have events assigned to them. This option is available for those use cases - creating static content for a column. If you wish to create dynamic content (i.e. based on other data in the row), the `dt-init columns.render` option should be used.
Additionally, this option can be useful when loading JSON data, as the value set here will be used if the cell value from the JSON is found to be null (for example, you might set a default string of `string Not available`.
</description>
<example title="Show an information message for a field that can have a `null` or `undefined` value"><![CDATA[
$('#example').dataTable( {
"columns": [
null,
null,
null,
{
"data": "first_name", // can be null or undefined
"defaultContent": "<i>Not set</i>"
}
]
} );
]]></example>
<example title="Show an empty string when a field's value is `null` or `undefined` value"><![CDATA[
$('#example').dataTable( {
"columns": [
null,
null,
null,
{
"data": "office", // can be null or undefined
"defaultContent": ""
}
]
} );
]]></example>
<example title="Create an edit button in the last column with `dt-init columnDefs`"><![CDATA[
$('#example').dataTable( {
"columnDefs": [
{
"data": null,
"defaultContent": "<button>Edit</button>",
"targets": -1
}
]
} );
]]></example>
<example title="Create an edit button in the last column with `dt-init columns`"><![CDATA[
$('#example').dataTable( {
"columns": [
null,
null,
null,
{
"data": null,
"defaultContent": "<button>Edit</button>"
}
]
} );
]]></example>
<related type="option">columns.data</related>
<related type="option">columns.render</related>
</dt-option>
|