Commit 63ee6cbc authored by Jérome Perrin's avatar Jérome Perrin

handsontable: expose handsontable configuration on gadget render method

parent 60ab3ff6
......@@ -4,15 +4,15 @@
"use strict";
rJS(window)
.declareMethod('render', function (content) {
.declareMethod('render', function (content, options) {
var data = JSON.parse(content);
return this.getElement()
.push(function (element) {
$(element).find('.table-container')
.handsontable({
.handsontable($.extend({
data: data,
stretchH: 'all'
});
}, options || {}));
});
})
......
......@@ -54,6 +54,35 @@
})
.always(start);
});
test("the gadget can be configured", function () {
var hstable_gadget;
stop();
g.declareGadget("./index.html", {
element: document.querySelector("#qunit-fixture")
})
.then(function (new_gadget) {
hstable_gadget = new_gadget;
return hstable_gadget.render(sample, {minSpareRows: 1});
})
.then(function () {
var rows = $('table tbody tr');
// There is one spare row
equal(rows.length, 4);
})
.then(function () {
return hstable_gadget.getData();
})
.then(function (data) {
equal(data, JSON.stringify([
["row1", "data11", "data12", "data13"],
["row2", "data21", "data22", "data23"],
["row3", "data31", "data32", "data33"],
[null, null, null, null]]));
})
.always(start);
});
});
}(rJS, JSON, QUnit, jQuery));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment