剑道UI工具栏格模板下拉选择出错(文本框而不是下拉) [英] Kendo UI grid toolbar template Dropdown selector Error (textbox instead of dropdown)

查看:297
本文介绍了剑道UI工具栏格模板下拉选择出错(文本框而不是下拉)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我一直在寻找到得到这个工作,但到目前为止,而不是一个下拉我得到空文本框而没有做任何事情的。

Example I've been looking into getting this to work but so far instead of a dropdown I get and empty textbox which doesn't do anything.

下面是我的present code: -

Below is my present code:-

@section js {
<script type="text/x-kendo-template" id="template">
    <div class="toolbar">
        <label class="category-label" for="external">Show checks by ex:</label>
        <input type="search" id="external" style="width: 230px"></input>
    </div>
</script>
<script type="text/javascript">
    var theGrid;
    $().ready(function () {
        $('#listDiv').kendoGrid({
            dataSource: {
                type: 'json',
                serverPaging: true,
                pageSize: 10,
                transport: {
                    read: {
                        url: '@Url.Action("_IList", "Entry", new { @ExId = Model.ExId })',
                        data: { ignore: Math.random() }
                    }
                },
                schema: {
                    model: {
                        id: 'Id',
                        fields: {
                            Id: { type: 'number' },
                            Name: { type: 'string' },
                            Ex: { type: 'string' },
                            Date: { type: 'string' },
                            Check1: { type: 'string' },
                            Check2: { type: 'string' },
                            Check3: { type: 'string' },
                            Check4: { type: 'string' },
                            Check5: { type: 'string' },
                            Edit: { type: 'string' }
                        }
                    },
                    data: "Data",
                    total: "Count"
                }
            },
            scrollable: false,
            toolbar: kendo.template($("#template").html()),
            columns:
                [
                    {
                        field: 'Name'
                    },
                    {
                        field: 'Ex'
                    },
                    {
                        field: 'Date'
                    },
                    {
                        template: '#=Template1#' + sitePath + '#=Patient1#',
                        field: 'Patient1',
                        title: 'Patient 1',
                        width: 50
                    },
                    {
                        template: '#=Template2#' + sitePath + '#=Patient2#',
                        field: 'Patient2',
                        title: 'Patient 2',
                        width: 50
                    },
                    {
                        template: '#=Template3#' + sitePath + '#=Patient3#',
                        field: 'Patient3',
                        title: 'Patient 3',
                        width: 50
                    },
                    {
                        template: '#=Template4#' + sitePath + '#=Patient4#',
                        field: 'Patient4',
                        title: 'Patient 4',
                        width: 50
                    },
                    {
                        template: '#=Template5#' + sitePath + '#=Patient5#',
                        field: 'Patient5',
                        title: 'Patient 5',
                        width: 50
                    }

                ],
            pageable: true
        });
        var dropDown = grid.find("#external").kendoDropDownList({
            dataTextField: "ExName",
            dataValueField: "ExId",
            autoBind: false,
            optionLabel: "All",
            dataSource: {
                type: "json",
                severFiltering: true,
                transport: {
                    url: '@Url.Action("_Ex", "Entry")',
                    data: { ignore: Math.random() }
                }
            },
            change: function () {
                var value = this.value();
                if (value) {
                    grid.data("kendoGrid").dataSource.filter({ field: "ExId", operator: "eq", value: parseString(value) });
                } else {
                    grid.data("kendoGrid").dataSource.filter({});
                }
            }
        });
        theGrid = $('#listDiv').data('kendoGrid');
    });        
</script>
<style scoped="scoped">
    #grid .k-toolbar
    {
        min-height: 27px;
    }
    .external-label
    {
        vertical-align: middle;
        padding-right: .5em;
    }
    #external
    {
        vertical-align: middle;
    }
    .toolbar {
        float: right;
        margin-right: .8em;
    }
</style>
}
<h2>Check Lists</h2>

<div id="listDiv"></div>
<br />

它的工作原理来显示每个前所有检查表,我可以一个previous页面上选择并字符串ID传递给这一个,但我希望能够弄清楚什么是错与工具栏模板具有1页,而不是小号$ p $垫过2的功能更为可取的。

It works to display all check lists for each Ex which I can select on a previous page and pass in the string Id to this one but I'd like to be able to figure out what's wrong with with the toolbar template as having the functionality on 1 page rather than spread over 2 is far more desirable.

任何帮助/指导将大大AP preciated。

Any help/guidance will be much appreciated.

编辑:

我也没找别人谁碰到的问题只是他们没有得到一个论坛的回应。
<一href=\"http://www.kendoui.com/forums/ui/grid/dropdownlist-in-toolbar-showing-as-a-text-box-so-doesn-t-work.aspx\"相对=nofollow>例2

I did also find someone else who encountered the problem except they didn't get a forum response. Example 2

推荐答案

您提到别人遇到的问题并没有得到响应,但链接的论坛主题也包含回应和回答这个问题。在这种特定情况下发生了哪些$ P $无法正确初始化pvented下拉页面上的JavaScript错误,我相信这也是你自己的情况。

You mention that somebody else encountered the problem and didn't receive a response, however the linked forum thread does contain a response and an answer to this issue. In that particular case a Javascript error had occurred on the page which prevented the dropdown from initializing correctly and I believe this is also the case for yourself.

虽然不能完全工作,因为没有一个有效的数据源,我把你的榜样code和倾倒入一个的的jsfiddle ,你可以看到下拉菜单出现精绝(定影一些JS错误后)。

Although not completely working because there isn't a valid datasource, I took your example code and dumped it into a jsFiddle and (after fixing some JS errors) you can see that the dropdown appears absolutely fine.

在特定的,有关于误差电网 sitePath 没有被定义的$ P $从pvented下拉初始化。

In particular, there were errors regarding grid and sitePath not being defined that prevented the dropdown from initializing.

    var grid;
    var sitePath = '';
    $().ready(function () {
        grid = $('#listDiv').kendoGrid({
            dataSource: {
                type: 'json',
                serverPaging: true,
                pageSize: 10,
                transport: {
                    read: {
                        url: '',
                        data: { ignore: Math.random() }
                    }
                },
                schema: {
                    model: {
                        id: 'Id',
                        fields: {
                            Id: { type: 'number' },
                            Name: { type: 'string' },
                            Ex: { type: 'string' },
                            Date: { type: 'string' },
                            Check1: { type: 'string' },
                            Check2: { type: 'string' },
                            Check3: { type: 'string' },
                            Check4: { type: 'string' },
                            Check5: { type: 'string' },
                            Edit: { type: 'string' }
                        }
                    },
                    data: "Data",
                    total: "Count"
                }
            },
            scrollable: false,
            toolbar: kendo.template($("#template").html()),
            columns:
                [
                    {
                        field: 'Name'
                    },
                    {
                        field: 'Ex'
                    },
                    {
                        field: 'Date'
                    },
                    {
                        template: '#=Template1#' + sitePath + '#=Patient1#',
                        field: 'Patient1',
                        title: 'Patient 1',
                        width: 50
                    },
                    {
                        template: '#=Template2#' + sitePath + '#=Patient2#',
                        field: 'Patient2',
                        title: 'Patient 2',
                        width: 50
                    },
                    {
                        template: '#=Template3#' + sitePath + '#=Patient3#',
                        field: 'Patient3',
                        title: 'Patient 3',
                        width: 50
                    },
                    {
                        template: '#=Template4#' + sitePath + '#=Patient4#',
                        field: 'Patient4',
                        title: 'Patient 4',
                        width: 50
                    },
                    {
                        template: '#=Template5#' + sitePath + '#=Patient5#',
                        field: 'Patient5',
                        title: 'Patient 5',
                        width: 50
                    }

                ],
            pageable: true
        });
        var dropDown = grid.find("#external").kendoDropDownList({
            dataTextField: "ExName",
            dataValueField: "ExId",
            autoBind: false,
            optionLabel: "All",
            dataSource: {
                type: "json",
                severFiltering: true,
                transport: {
                    url: '@Url.Action("_Ex", "Entry")',
                    data: { ignore: Math.random() }
                }
            },
            change: function () {
                var value = this.value();
                if (value) {
                    grid.data("kendoGrid").dataSource.filter({ field: "ExId", operator: "eq", value: parseString(value) });
                } else {
                    grid.data("kendoGrid").dataSource.filter({});
                }
            }
        });
        theGrid = $('#listDiv').data('kendoGrid');
    });     

这篇关于剑道UI工具栏格模板下拉选择出错(文本框而不是下拉)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆