xorcery / TableEditor

11 stars 8 forks source link

Clear table only works for init model value #11

Open bjarnef opened 8 years ago

bjarnef commented 8 years ago

It seems "Clear table" button only works for init model value.

If you change values in the table cells and click on "Clear table" it doesn't reset the cell values.

.. or it seems to work on first click, but not on subsequent clicks.

If I change this:

$scope.clearTable = function () {
        if (confirm("Are you sure you wish to remove everything from the table?")) {
            $scope.model.value = defaultModel;
        }
    }

to this it seems to work:

$scope.clearTable = function () {
        if (confirm("Are you sure you wish to remove everything from the table?")) {
            $scope.model.value = {
        useFirstRowAsHeader: false,
        useLastRowAsFooter: false,
        tableStyle: null,
        columnStylesSelected: [
           null,
           null
        ],
        rowStylesSelected: [
           null,
           null,
           null
        ],
        cells: [
            [{ value: "" }, { value: ""}],
            [{ value: "" }, { value: ""}],
            [{ value: "" }, { value: ""}],
        ]
    };
        }
    }