//資料
var data = [
{id: 2, name : "約翰", isActive: false, 顏色: "黑色"},
{id: 3, 姓名: "Al 名稱: "Ben", isActive: false, color: "blue"}
];
unction (instance, td, row, col, prop, value, cellProperties) {
Handsontable.TextCell.renderer.apply(this, argument);
背景: '黃色'
});
//綠色渲染方法
var greenRenderer = function (instance, td, row, col, prop, value,cellPropertcheap ;
$(td }).css({
背景: '綠色'
// 初始化
var $container = $("#範例1"); 資料:數據,
s: true,
minSpareRows: 1,
”},
{data: "name", type: {renderer: YellowRenderer}}, //黃色渲染
{ 資料: "color",
type: Handsontable.AutocompleteCell, //自動完成者
green", "blue", "gray", "black " , "white"] //資料來源
}
row, col, prop) {
if (row === 0 && col === 0) {
}
});
注意是div容器載入完了之後進行初始化:
demo代碼:
基本示範< ;/title>
基本示範< ;/title>
="jquery.handsontable.full.css">
<script><BR> $(function(){<BR> <BR> {id: 1, name: " Ted", isActive: true, color: "orange"},<BR> {id: 2, name: "John", isActive: f : " Al", isActive: true, 顏色: "紅色"},<BR> {id: 4, 姓名: "Ben", isActive: false, 顏色: "藍色「} <BR> // <BR> // <BR> // <BR> // <BR> // <BR> // <BR> // <BR> // <BR> // <BR> // <<<BR> var yellowRenderer = function(實例,td,row,col,col,prop,prop,value,cellproperties){<BR>handsontable.textcell.renderer.apply(此) , (td).css({<BR> 背景: '黃色'<BR> //綠色渲染法<BR> var greenRenderer = function (實例、td、使用、列、屬性、值、cellProperties) {<BR> Handsontable.TextCell.renderer.apply(this, 參數);<BR> 背景: '綠色' <BR> });<BR> };<BR> // 初始化<BR> $container.handsontable({<BR> 資料:數據,<BR> colHeaders: true,<BR> minSpareRows: 1,<BR> {資料: " id"},<BR> {資料:「名稱」,而類型:{渲染器: YellowRenderer}}, //黃色渲染<BR> {data: "isActive", type: Handsontable.CheckboxCell}, //多選框<BR> type: Handsontable.AutocompleteCell, //自動完成<BR> source: ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"] //資料來源<BR> }<BR> ],<BR> cells: function (row, col, prop) {<BR> if (row === 0 && col === 0) {<BR> return {type: {renderer: greenRenderer}};<BR> }<BR> }<BR> });<BR> });<BR> </script>