# Select Grid Rows Programmatically Based on the DataItem

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Progress® Kendo UI® Grid for jQuery</td>
 </tr>
 <tr>
  <td>Product Version</td>
  <td>Tested up to version 2017.2 621</td>
 </tr>
</table>

## Description

I want to have a Grid with some of its checkboxes checked by default when it loads. How can I check checkboxes programmatically by using the selectable column in the Kendo UI Grid?

## Solution

1. In the [`dataBound`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/grid/events/databound) event handler, get the rows with the [`items()`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/grid/methods/items) method of the grid.
2. Loop through the rows by using the jQuery [`each`](https://api.jquery.com/each/) method.
3. Get every row data by using the [`dataItem`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/grid/methods/dataitem) method.
4. Set the current row as selected by using the [`select`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/grid/methods/select) method.

```dojo
<div id="example">
    <div id="grid"></div>

    <script>
        $(document).ready(function() {
            $("#grid").kendoGrid({
                dataSource: {
                    pageSize: 10,
                    transport: {
                        read: {
                            url: "https://demos.telerik.com/service/v2/core/Products"
                        }
                    },
                    schema: {
                        model: {
                            id: "ProductID"
                        }
                    }
                },
                pageable: true,
                dataBound: function(e) {
                    var grid = this;
                    var rows = grid.items();

                    $(rows).each(function(e) {
                        var row = this;
                        var dataItem = grid.dataItem(row);

                        if (dataItem.UnitPrice >= 22) {
                            grid.select(row);
                        }

                    });
                },
                scrollable: false,
                persistSelection: true,
                sortable: true,
                columns: [{
                        selectable: true,
                        width: "50px"
                    },
                    {
                        field: "ProductName",
                        title: "Product Name"
                    },
                    {
                        field: "UnitPrice",
                        title: "Unit Price",
                        format: "{0:c}"
                    },
                    {
                        field: "UnitsInStock",
                        title: "Units In Stock"
                    },
                    {
                        field: "Discontinued"
                    }
                ]
            });
        });
    </script>
</div>
```

## Notes

The checkbox selectable column is available as of the Kendo UI R2 2017 SP1 release.

## See Also

* [Frequently Asked Questions on Checkbox Selection](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/grid-faq)
* [Grid Checkbox Selection Demo](https://demos.telerik.com/kendo-ui/grid/checkbox-selection)
* [API Reference for the columns.selectable Configuration](https://docs.telerik.com/kendo-ui/api/ui/grid/configuration/columns#columnsselectable)
