SlickGrid row id changes after filtering

I have a slickgrid with built-in filtering (using DataView). I assigned a unique identifier to each row of data, and I pass that identifier (not the row number) to a function that updates the div somewhere else in the user interface.

This works fine if I don't filter. But if I filter the column before passing the identifier, it changes the identifier to reflect the line #. It will even change the line identifier to line number.

This is just weird. Any idea what is going on ???

grid_msc.onClick.subscribe(function(e, args) {
    var cell = grid_msc.getCellFromEvent(e);
    var row = cell.row;             // get row #
    var row_ID = data_msc[row].id;  // get the row ID, not row #
    var msc = data_msc[args.row][grid_msc.getColumns()[args.cell].field];

    alert("Row#:"+row+", RowID:"+row_ID+", Value:"+msc);
    mscToUI(msc, row_ID);
});


// Add the selected item to the UI
    function mscToUI(addC, cellNum) {
        alert(addC+", "+cellNum);
        $('#selectedMsc').append('<a href="javascript:removemsc('+cellNum+')" id="'+cellNum+'" class="rSel"><img src="images/remove.png" align="texttop" border="0" style="padding-right:4px;">'+addC+'<br /></a>');
    }
})
+5
source share
1 answer

DataView, / (dataView_msc), (data_msc).

grid_msc.onClick.subscribe(function(e, args) {
  var cell   = grid_msc.getCellFromEvent(e);  // get the cell
  var row    = cell.row;  // get the row index (this value will change on filter/sort)
  var item   = dataView_msc.getItem(row);  // get the row item (see: object, data)
  var msc    = item[grid_msc.getColumns()[cell.cell].field];  // get the value of the cell

  alert("Row Index:"+row+", RowID:"+item.id+", Cell Value:"+msc);
  console.log(item);
  mscToUI(msc, item.id);
});

, mscToUI() row id. , (item) DataView:

  • getIdxById(id) - `
  • getItem(i) - , /
  • getItemById(id) - /
  • getItemByIdx(i) - , /
+14
source

All Articles