Kendo Grid Filterable cell

Nilesh

I have a requirement in which I have to show two dropdown list in the Filterable cell of kendo grid. These two dropdown lists would filter two different columns in the kendo grid.

One thought I had is having template which would be some kendo container like some panel probably, and then add two dropdowns to that container.

Is this even possible? If yes how to achieve this?

Here is my kendo grid definition.

ctrl.mainGridOptions = {
    dataSource: ctrl.gridDataSource,
    columns: [
                {
                    title: 'Col1-Col2',
                    field: 'Col1',
                    width: 200,
                    template: kendo.template($("#col1").html()),
                    filterable: { cell: { template: ctrl.coonetemplate, showOperators: false } }
                },
                {
                    field: 'Col3',
                    width: 150,
                    title: 'Col3',
                    template: kendo.template($("#col3").html()),
                    filterable: { cell: { template: ctrl.colthreeTemplate, showOperators: false } }
                }
         ]
      }

Here is a mockup of what I want to achieve.

enter image description here

Brady Mulhollem

There are a few different parts to this.

First, if you want to have multiple filter controls for different pieces of data, you should define a column for each one. Then, put a template on the first column to have it display the data for two columns. Use the attributes option to set a colspan=2. Then, use the attributes option on the second columns to set style="display:none".

The second part is getting the dropdowns. I generally prefer to use the "values" option to accomplish this. The code below uses this for the OrderID column. The other alternative was the approach you were on, which is to use the cell template. The code below uses this on the ShipName column.

    <div id="example">
        <div id="grid"></div>
        <script>
            $(document).ready(function() {
                $("#grid").kendoGrid({
                    dataSource: {
                        type: "odata",
                        transport: {
                            read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
                        },
                        schema: {
                            model: {
                                fields: {
                                    OrderID: { type: "string" },
                                    Freight: { type: "number" },
                                    ShipName: { type: "string" },
                                    OrderDate: { type: "date" },
                                    ShipCity: { type: "string" }
                                }
                            }
                        },
                        pageSize: 20,
                        serverPaging: true,
                        serverFiltering: true,
                    },
                    height: 550,
                    filterable: {
                        mode: "row"
                    },
                    pageable: true,
                    columns: 
                    [{
                        field: "OrderID",
                        width: 150,
                        attributes: {
                            colspan: 2
                        },
                        values: [{text: "10248", value: "one"},{text:"10249", value: "two"}],
                        template: '#:OrderID# (#:ShipName#)',
                        filterable: {
                            cell: {
                                operator: "eq",
                                showOperators: false
                            }
                        }
                    },
                    {
                        attributes: {
                            style: "display:none"
                        },
                        field: "ShipName",
                        width: 200,
                        title: "Ship Name",
                        filterable: {
                            cell: {
                                template: function(args) {
                                    args.element.kendoDropDownList({
                                        dataSource: args.dataSource,
                                        dataTextField: "ShipName",
                                        dataValueField: "ShipName",
                                        valuePrimitive: true
                                    });
                                },
                                operator: "eq",
                                showOperators: false
                            }
                        }
                    },{
                        field: "Freight",
                        width: 255,
                        filterable: false
                    }
                  ]
                });
            });
        </script>
    </div>

Runnable Demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Kendo Grid Filterable cell

From Dev

Clickable Cell in Kendo Grid

From Dev

Accessing kendo grid cell values

From Dev

Kendo grid editable multiselect grid cell

From Dev

How do I display Kendo Grid inside Kendo Grid cell?

From Dev

kendo grid select cell data on focus

From Dev

Show dropdown in cell of kendo grid in template

From Dev

How to show € symbol in a kendo grid cell

From Dev

how to get cell click event in kendo grid

From Dev

Make cell readonly in Kendo Grid if condition is met

From Dev

Kendo Grid: Removing dirty cell indicators

From Dev

Kendo grid cell refocusing after refresh

From Dev

Styling cell in Kendo grid via ClientTemplate

From Dev

Remote update cell content in kendo grid

From Dev

how to focus next cell in kendo grid by enter

From Dev

Kendo UI grid filter cell that contains an array

From Dev

Kendo grid change style cell data

From Dev

how to focus next cell in kendo grid by enter

From Dev

Kendo UI grid conditionally editable cell

From Dev

How to mark Kendo Grid's cell as edited?

From Dev

Kendo UI grid filter cell that contains an array

From Dev

make a kendo cell readonly based on dropdownselection in the grid

From Dev

Kendo UI, How to manually call validate() on kendo grid cell

From Dev

Kendo UI, How to manually call validate() on kendo grid cell

From Dev

Update Kendo Grid selected cell value with the value in a Kendo Editor

From Dev

Change Kendo Grid Cell With Ajax Response When Another Cell Changes

From Dev

Kendo UI combobox with filterable multi columns

From Dev

how to clear the little red flag in the corner of the kendo grid cell

From Dev

Kendo UI: Conditionally preventing a Tooltip from being displayed on a Grid cell

Related Related

HotTag

Archive