javascript中的冲突动态控件 [英] Conflict dynamic controls in javascript

查看:136
本文介绍了javascript中的冲突动态控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,其中我有5列例如。在网格加载来自db的数据之后,我将使用jquery设计带有下拉列表的第一列。我计划通过使用jquery来增强第二列成为日期时间选择器。我已经成功添加了下拉列表,但是当我添加日期时间选择器时,下拉列表也将成为日期时间选择器。

我怀疑jquery是apppendTo(容器)中这两个设置之间的冲突但是不知道如何更改它,因为我仍然是jquery的新手,并搜索在线资料供参考但无济于事。以下是我的代码:



Hi, I have a gridview in which I have 5 columns for example. After the grid is loaded with data from db, I will have the first column designed with a dropdown using jquery. I plan to enhance the second column to become a datetime picker by using jquery too. I have successfully added the dropdown but when I added also the datetime picker, the dropdown will become datetime picker too.
I suspect the jquery is conflict between these 2 setting in the "apppendTo(container)" but would not sure how to change it as I am still newbie in jquery and have search online materials for reference but to no avail. Below are my codes:

grid = $('#gdInformation').kendoGrid($.extend({
      //some setting here
       columns: [
       { field: "Region", title: "Region", width: 120,  editor: regionDropDownEditor},
       { field: "DateStart", title: "Date Start", editor: dateTimeEditor}]
}));










function regionDropDownEditor(container, options) {
    $('<input data-bind = "value: Region" required name"' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            dataTextField: "Region",
            dataValueField: "Region",
            dataSource: _regionNames //array containing items
        });
};
function dateTimeEditor(container, options) {
    $('<input data-bind = "value: DateStart" required name"' + options.field + '"/>')
        .appendTo(container)
        .kendoDateTimePicker({
            value: new Date(),
            dateInput: true,
            format: "MM/dd/yyyy HH:mm:ss"
        });
};





我很确定问题来自appendTo()但是我需要如何改变它?谢谢。



我的尝试:



1.更改将appendTo(container)改为appendTo(options.field)但无济于事。

2.搜索互联网以供参考但只找到appendTo()基本用法。



I am quite sure the problem is coming from the "appendTo()" but how I need to change it? Thank you.

What I have tried:

1. Change the "appendTo(container)" into "appendTo(options.field)" but to no avail.
2. Search internet for reference but only found the appendTo() basic usage.

推荐答案

('#gdInformation')。kendoGrid(
('#gdInformation').kendoGrid(


.extend({
//这里的一些设置
列:[
{field:Region,title:Region,width:120,editor:regionDropDownEditor},
{field:DateStart,title:Date Start,editor:dateTimeEditor} ]
}));
.extend({ //some setting here columns: [ { field: "Region", title: "Region", width: 120, editor: regionDropDownEditor}, { field: "DateStart", title: "Date Start", editor: dateTimeEditor}] }));










function regionDropDownEditor(container, options) {


('< input data-bind =value:Regionrequired name'+ options.field +'/>')
。 appendTo(container)
.kendoDropDownList({
dataTextField:Region,
dataValueField:Region,
dataSource:_regionNames //包含项目的数组
});
};
函数dateTimeEditor(容器,选项){
('<input data-bind = "value: Region" required name"' + options.field + '"/>') .appendTo(container) .kendoDropDownList({ dataTextField: "Region", dataValueField: "Region", dataSource: _regionNames //array containing items }); }; function dateTimeEditor(container, options) {


这篇关于javascript中的冲突动态控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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