Skip to content

Commit

Permalink
[datopian#384, slickgrid][s]: slickgrid add support for row-add and r…
Browse files Browse the repository at this point in the history
…ow-delete
  • Loading branch information
aliounedia committed Jan 20, 2014
1 parent 66daf6f commit a046861
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/view.slickgrid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*jshint multistr:true */

this.recline = this.recline || {};
Expand Down Expand Up @@ -477,4 +476,3 @@ my.SlickGrid = Backbone.View.extend({
$.extend(true, window, { Slick:{ Controls:{ ColumnPicker:SlickColumnPicker }}});
})(jQuery);

/*jshint multistr:true */
71 changes: 71 additions & 0 deletions test/view.slickgrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,77 @@ test('editable', function () {
view.remove();
});

test('delete-row' , function(){
var dataset = Fixture.getDataset();
var view = new recline.View.SlickGrid({
model: dataset,
state: {
hiddenColumns:['x','lat','title'],
columnsOrder:['lon','id','z','date', 'y', 'country'],
columnsWidth:[
{column:'id',width: 250}
],
gridOptions: {editable: true , "enabledDelRow":true},
columnsEditor: [{column: 'country', editor: Slick.Editors.Text}]
}
});

$('.fixtures .test-datatable').append(view.el);
view.render();
view.show();
old_length = dataset.records.length
dataset.records.on('remove', function(record){
equal(dataset.records.length, old_length -1 );
});

// Be sure a cell change triggers a change of the model
e = new Slick.EventData();
view.grid.onClick.notify({
row: 1,
cell: 0,
grid: view.grid
}, e, view.grid);

view.remove();


});

test('add-row' , function(){
//To test adding row on slickgrid , we add some menu GridControl
//I am based on the FlotControl in flot wiewer , to add a similary
//to the sclickgrid , The GridControl add a bouton menu
//one the .side-bar place , which will allow to add a row to
//the grid on-click

var dataset = Fixture.getDataset();
var view = new recline.View.SlickGrid({
model: dataset,
state: {
hiddenColumns:['x','lat','title'],
columnsOrder:['lon','id','z','date', 'y', 'country'],
columnsWidth:[
{column:'id',width: 250}
],
gridOptions: {editable: true , "enabledAddRow":true},
columnsEditor: [{column: 'country', editor: Slick.Editors.Text}]
}
});

// view will auto render ...
assertPresent('.recline-row-add', view.elSidebar);
// see recline.SlickGrid.GridControl widget
//view.render()
old_length = dataset.records.length
dataset.records.on('add',function(record){
equal(dataset.records.length ,old_length + 1 )
});

view.elSidebar.find('.recline-row-add').click();

});


test('update', function() {
var dataset = Fixture.getDataset();
var view = new recline.View.SlickGrid({
Expand Down

1 comment on commit a046861

@rufuspollock
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah apologies - just saw that you corrected white-space issues i commented on in previous commit :-)

Please sign in to comment.