John Fehr
John Fehr

Reputation: 121

kendoDropDownList resetting inside kendoGrid after sort

I've added a kendoDropDownList in one of the cells in a kendoGrid, and it works fine at first. However, when I click on a column header to sort, the cell loses its formatting. Anyone have any idea how to prevent this? Here's a simple sample:

<html>
<head>
    <title>test</title>
    <link href="/kendoui.web.2013.2.716.open-source/styles/kendo.common.min.css" rel="stylesheet" type="text/css"/>
    <link href="/kendoui.web.2013.2.716.open-source/styles/kendo.default.min.css" rel="stylesheet" type="text/css"/>
    <script src="/kendoui.web.2013.2.716.open-source/js/jquery.min.js"></script>
    <script src="/kendoui.web.2013.2.716.open-source/js/kendo.web.min.js" type="text/javascript"></script>
</head>
<body>
    <table class="gridTable">
        <thead>
        <tr>
            <th data-field="name">Name</th>
            <th data-field="options">Options</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td class="wrap">Item</td>
            <td>
                <select class="menuBar" style="width:80px;">
                    <option>Big</option>
                    <option>Medium</option>
                    <option>Small</option>
                </select>
            </td>
        </tr>

        </tbody>
    </table>
    <script type="text/javascript">
        $(document).ready(function() {
            $(".gridTable").kendoGrid({
                sortable: true
            });

            $(".menuBar").kendoDropDownList({
            });
        });
    </script>
</body>
</html>

Upvotes: 0

Views: 876

Answers (1)

Petur Subev
Petur Subev

Reputation: 20203

The Grid is reconstructed each time you perform Page/Sort/Group etc. For such cases you need to use the dataBound event of the Grid to re-initialize any widgets or executed any JavaScript code that affects what is displayed in the Grdi.

Upvotes: 2

Related Questions