This is a migrated thread and some comments may be shown as answers.

Drop down list in grid

2 Answers 305 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Megha
Top achievements
Rank 1
Megha asked on 09 Dec 2011, 07:13 AM
I want to show dropdownlist in grid, could you tell me how it is posssible?

2 Answers, 1 is accepted

Sort by
0
James Lamar
Top achievements
Rank 1
answered on 22 Dec 2011, 05:52 PM
Try initializing the grid from a table. I have tried a few samples with a grid populated from remote JSON, but I cannot get any kendo styling or functionality to work inside the grid that way. You can simple include a "select" form tag as your template though and you will get a drop down inside the grid, albeit, not a pretty one :)

Here is the code for the first example:

<div id="example" class="k-content">
                <table id="grid">
                    <thead>
                        <tr>
                            <th data-field="rank">Rank</th>
                            <th data-field="rating">Rating</th>
                            <th data-field="title">Title</th>
                            <th data-field="year">Year</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>1</td>
                            <td>9.2</td>
                            <td><input class="titles"/></td>
                            <td>1994</td>
                        </tr>
                        <tr>
                            <td>2</td>
                            <td>9.2</td>
                            <td><input class="titles"/></td>
                            <td>1972</td>
                        </tr>
                        <tr>
                            <td>3</td>
                            <td>9</td>
                            <td><input class="titles"/></td>
                            <td>1974</td>
                        </tr>
                        <tr>
                            <td>4</td>
                            <td>8.9</td>
                            <td><input class="titles"/></td>
                            <td>1966</td>
                        </tr>
                        <tr>
                            <td>5</td>
                            <td>8.9</td>
                            <td><input class="titles"/></td>
                            <td>1994</td>
                        </tr>
                        <tr>
                            <td>6</td>
                            <td>8.9</td>
                            <td><input class="titles"/></td>
                            <td>1957</td>
                        </tr>
                        <tr>
                            <td>7</td>
                            <td>8.9</td>
                            <td><input class="titles"/></td>
                            <td>1993</td>
                        </tr>
                        <tr>
                            <td>8</td>
                            <td>8.8</td>
                            <td><input class="titles"/></td>
                            <td>1975</td>
                        </tr>
                        <tr>
                            <td>9</td>
                            <td>8.8</td>
                            <td><input class="titles"/></td>
                            <td>2010</td>
                        </tr>
                        <tr>
                            <td>10</td>
                            <td>8.8</td>
                            <td><input class="titles"/></td>
                            <td>2008</td>
                        </tr>
                    </tbody>
                </table>

<script>
$(document).ready(function() {
  $("#grid").kendoGrid({
    height: 250
  });
});
$(document).ready(function(){
     $(".titles").kendoDropDownList([{text: "Item1", value: "1"}, {text: "Item2", value: "2"}]);
  });
</script>


Here is an example of the select form as a template:

{ field: "COL_NAME", title: "COL_NAME", template: "<select name='COL_NAME'><option>Item 1</option><option>Item 2</option><option>Item 3</option></select>"}


Hope that helps!
0
Leo
Top achievements
Rank 1
answered on 22 Dec 2011, 07:12 PM
Hi Megha,

You may also want to try to load the grid data from XML.

In turn, the XML can contain CDATA with HTML and/or Javascript code.



So, for example, in my action I return the following XML snippet:


Here, I can embed HTML and/or Javascript code that in turn adds functionality to my page/widgets.



In your HTML page, you would do something like this to load the data:

var dataSource = new kendo.data.DataSource({
    transport: {
        read: "/site/GetBooksXML.action"
        },
        schema: {...


I’m using a Java action to build my XML string but you can use whatever technology you may require for your purpose.

This is something that I’m working on so I hope it helps you resolve your issue.

Tags
Grid
Asked by
Megha
Top achievements
Rank 1
Answers by
James Lamar
Top achievements
Rank 1
Leo
Top achievements
Rank 1
Share this question
or