0
votes

I am trying to select the specific row (row with today's date) of grid after its creation.

Please find the following function which I am calling after creating the grid.

Here, sgDataView is dataview and sgGrid is already loaded slick grid

function SetDefaultDateSelected() {
    for (var rowIndex = 0; sgDataView.getLength(); rowIndex++) {
        var gridRow = sgDataView.getItem(rowIndex);
        if (gridRow.Date == $.datepicker.formatDate('dd-M-yy', new Date())) {
            sgGrid.setSelectedRows(gridRow);
            sgGrid.scrollRowIntoView(rowIndex);
            break;
        }
    }
}

Could anyone please let me know why sgGrid.setSelectedRows(gridRow); is not setting the selected row?

Please let me know in case of any other approach.

1

1 Answers

2
votes

SlickGrid's function setSelectedRows does not accept a)single values b)items, it needs indexes of items

so basically you need sgGrid.setSelectedRows([rowIndex]); instead of sgGrid.setSelectedRows(gridRow);