Asp.net mvc 4 剑道UI网格工具栏模板下拉列表选择器错误(文本框而不是下拉列表)

Asp.net mvc 4 剑道UI网格工具栏模板下拉列表选择器错误(文本框而不是下拉列表),asp.net-mvc-4,kendo-grid,Asp.net Mvc 4,Kendo Grid,我一直在研究如何让它发挥作用,但到目前为止,我得到的不是一个下拉列表,而是一个没有任何作用的空文本框 以下是我目前的代码:- @section js { <script type="text/x-kendo-template" id="template"> <div class="toolbar"> <label class="category-label" for="external">Show checks by ex:</l

我一直在研究如何让它发挥作用,但到目前为止,我得到的不是一个下拉列表,而是一个没有任何作用的空文本框

以下是我目前的代码:-

@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 />
@section js{
按ex显示支票:
电网电压;
$().ready(函数(){
$('#listDiv')。肯多格里德({
数据源:{
键入:“json”,
对,,
页面大小:10,
运输:{
阅读:{
url:“@url.Action(“_IList”,“Entry”,new{@ExId=Model.ExId})”,
数据:{忽略:Math.random()}
}
},
模式:{
型号:{
id:'id',
字段:{
Id:{type:'number'},
名称:{type:'string'},
例如:{type:'string'},
日期:{type:'string'},
检查1:{type:'string'},
检查2:{type:'string'},
检查3:{type:'string'},
检查4:{type:'string'},
检查5:{type:'string'},
编辑:{type:'string'}
}
},
数据:“数据”,
总数:“计数”
}
},
可滚动:false,
工具栏:kendo.template($(“#template”).html(),
柱:
[
{
字段:“名称”
},
{
字段:“Ex”
},
{
字段:“日期”
},
{
模板:'#=Template1#'+sitePath+'#=Patient1#',
字段:“Patient1”,
标题:“患者1”,
宽度:50
},
{
模板:'#=Template2'+sitePath+'#=Patient2',
字段:“Patient2”,
标题:“患者2”,
宽度:50
},
{
模板:'#=Template3'+sitePath+'#=Patient3',
字段:“Patient3”,
标题:“患者3”,
宽度:50
},
{
模板:'#=Template4'+sitePath+'#=Patient4',
字段:“Patient4”,
标题:“患者4”,
宽度:50
},
{
模板:'#=Template5'+sitePath+'#=Patient5',
字段:“Patient5”,
标题:“患者5”,
宽度:50
}
],
可分页:正确
});
var dropDown=grid.find(#external”).kendoDropDownList({
dataTextField:“ExName”,
数据值字段:“ExId”,
自动绑定:错误,
选项标签:“全部”,
数据源:{
键入:“json”,
是的,
运输:{
url:“@url.Action”(“条目”),
数据:{忽略:Math.random()}
}
},
更改:函数(){
var value=this.value();
如果(值){
grid.data(“kendoGrid”).dataSource.filter({field:“ExId”,operator:“eq”,value:parseString(value)});
}否则{
grid.data(“kendoGrid”).dataSource.filter({});
}
}
});
网格=$('#listDiv')。数据('kendoGrid');
});        
#grid.k工具栏
{
最小高度:27px;
}
.外部标签
{
垂直对齐:中间对齐;
右侧填充:.5em;
}
#外部的
{
垂直对齐:中间对齐;
}
.工具栏{
浮动:对;
右边距:.8em;
}
}
检查表

它可以显示每个Ex的所有检查列表,我可以在上一页上选择并将字符串Id传递给这个Ex,但我希望能够找出工具栏模板的错误,因为将功能放在一页上而不是分散在两页上是更可取的

任何帮助/指导都将不胜感激

编辑:

我也发现有人遇到了这个问题,只是他们没有得到论坛的回复。

您提到其他人遇到了该问题,但没有收到回复,但是链接的论坛线程确实包含对此问题的回复和答案。在这种情况下,页面上发生了Javascript错误,导致下拉菜单无法正确初始化,我相信你自己也是如此

虽然由于没有有效的数据源,所以无法完全工作,但我将您的示例代码转储到了中,并且(在修复了一些JS错误之后)您可以看到下拉列表看起来非常好

特别是,由于未定义
grid
sitePath
而导致下拉列表无法初始化,因此出现了一些错误

    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');
    });     

他们得到的回复没有回答问题,而是说答案在支持票回复中,ofc不是公开的,因此没有回复,因为该论坛没有提供解决方案。当我明天开始工作的时候,我会研究测试你的代码。公共论坛确实提到页面中的其他Javascript错误是罪魁祸首,我相信