[slickgrid] How to loop through rows which are outside canvas?

Posted by RAY.D
2015. 4. 27. 10:15 Web/Slickgrid
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



slickgrid - How to loop through rows which are outside canvas?



Q

I am having some markers on map and same number of rows in slickgrid?

What I want is when a marker is clicked the id of marker is matched with all rows and corresponding row should get selected.

Here is my code:

var $canvas = $(grid.getCanvasNode());
var $allRows = $canvas.find('.slick-row');

    $($allRows).each(function() {
        if ($(this).rowID == selectedMarker) {
            $(this).addClass("active-row"); 
            grid.scrollRowIntoView($(this).index());
        }
    });

It works fine only when the row which I want is present in the grid but the grid DOM contains only 8 rows at a time (The grid has 30 rows).

How can I loop through all data?





A.

You shouldn't be modifying SlickGrid's DOM at all. SlickGrid will overwrite any changes as it's only rendering the rows in view (with some buffer). When you scroll past that buffer any changes you made to the DOM are lost.

You have to change the row's data and allow SlickGrid to add the appropriate classes to the DOM when it's rendering.

Edit:

SlickGrid setup:

dataView.getItemMetadata = metadata(dataView.getItemMetadata);

function metadata(metadataProvider) {
  return function(row) {
    var item = this.getItem(row),
        ret = metadataProvider(row);

    if (item && item.isActive) {
      ret = ret || {};
      ret.cssClasses = (ret.cssClasses || '') + ' active-row';
    }

    return ret;
  };
}

Then when you click on a marker:

var item = dataView.getItemById(selectedMarker);
var row  = dataView.getRowById(selectedMarker);
item.isActive = true;
dataView.updateItem(item.id, item);
grid.scrollRowIntoView(row);



http://stackoverflow.com/questions/16071025/slickgrid-how-to-loop-through-rows-which-are-outside-canvas

'Web > Slickgrid' 카테고리의 다른 글

Slickgird : Add empty row with message “No results found”  (0) 2015.04.27
MVC3에서 slickgrid 쓰임새  (0) 2015.04.27