Slickgrid onClick... How to update dataView without global dataView?

298 views Asked by At

Short version: Is it possible to access the dataView within the scope of this subscription method?

grid.onClick.subscribe(function(e, args) {
    var rowData= args.grid.getDataItem(args.row);

    //want to update data in dataView for this row

});

(Elsewhere in my module i have)

dataView.onRowsChanged.subscribe(function(e, args){
    grid.invalidateRows(args.rows);
    grid.render();
});

Long Version: I've created a generic JavaScript module for Slickgrid within my application for reuse. It takes a columnCollection, dataCollection, filterArgs, filterMethods, and now i'm in a scenario where there is some business logic in an onClick that, from an organization standpoint, i don't want in my generic module. If i were to pass a clickMethod to my module, how would i update the dataView on click. (I hope this makes sense.)

Module would be something like...

var options = _.extend(DEFAULT_OPTIONS, params.options);
var dataView = new Slick.Data.DataView({inlineFilters:true});
var grid = new Slick.Grid('#grid', dataView, params.columnsObj, options);

if(options.myClickMethod !== undefined){
    grid.onClick.subscribe(function(e,args){
        options.myClickMethod(e,args);
    });
}
1

There are 1 answers

0
Rilo On BEST ANSWER

grid.getData() actually returns a dataView object

var dataView = args.grid.getData();