Handsontable

Initialise

      Var.grid = $("#rbmGrid").handsontable({
        columns: [
          { data: "Id", title: "ID", width: 50, cssClass: "cell-align-center", renderer: renderDefault },
          { data: "Name", title: "Name", width: 400, renderer: renderDefault },
          { data: "Phone", title: "Phone", width: 380, renderer: renderDefault },
          { data: "Fax", title: "Fax", width: 380, renderer: renderDefault }
        ],
        data: Var.Items,
        editor: false,
        disableVisualSelection: true,
        outsideClickDeselects: false,
        multiSelect: false,
        currentRowClassName: "currentRow",
        columnSorting: false,
        sortIndicator: false,
        readOnly: true,
        afterSelectionEnd: gridRowSelected,
        height: 400
      });

Get selected row

    function gridRowSelected(rowIndex) {
      Var.selectedRowIndex = rowIndex;
      var selected = Var.grid.handsontable("getSourceDataAtRow", rowIndex);
    }

Select a cell

        Var.grid.handsontable("selectCell", row, col);

(Re)Draw the table

        Var.grid.handsontable("loadData", items);
        $("#grid").handsontable("render");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License