Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 剑道UI:我可以使用数据源与标准HTML元素同步数据吗_C#_Jquery_Kendo Ui_Kendo Mvvm - Fatal编程技术网

C# 剑道UI:我可以使用数据源与标准HTML元素同步数据吗

C# 剑道UI:我可以使用数据源与标准HTML元素同步数据吗,c#,jquery,kendo-ui,kendo-mvvm,C#,Jquery,Kendo Ui,Kendo Mvvm,我很难将两个剑道的想法结合起来,我已经找到了单独的例子,但到目前为止还没有结合的例子 我有一个包含简单HTML元素(文本框、下拉列表等)的页面。我使用这个剑道示例将视图链接到viewmodel 这里一切正常。我可以更新视图、更改值并查看viewmodel中反映的所有内容 我有一个负责此数据的远程服务。我按照这个剑道示例为这个远程服务器创建了一个数据源 我定义了一个读取和更新传输(因为这是我唯一需要的传输),并且为数据定义了一个模式,具有一个有效的id。所有这些都可以工作。当我手动调用read

我很难将两个剑道的想法结合起来,我已经找到了单独的例子,但到目前为止还没有结合的例子

我有一个包含简单HTML元素(文本框、下拉列表等)的页面。我使用这个剑道示例将视图链接到viewmodel

这里一切正常。我可以更新视图、更改值并查看viewmodel中反映的所有内容

我有一个负责此数据的远程服务。我按照这个剑道示例为这个远程服务器创建了一个数据源

我定义了一个读取和更新传输(因为这是我唯一需要的传输),并且为数据定义了一个模式,具有一个有效的id。所有这些都可以工作。当我手动调用read时,数据源向服务发出读取请求,然后返回数据

我见过很多将数据源绑定到剑道网格、下拉列表等的示例。我不知道如何将数据源返回的数据绑定到页面中的元素

我甚至不能通过使用Chrome开发工具进行探索来一起破解一些东西,尽管最终我想要的不仅仅是破解。我希望,无论解决方案是什么,它都能扩展到我正在工作的整个站点


最好的方法是什么?我觉得我误解了这是怎么回事

在KendoDojo的第一个链接中,在
viewModel
中,我创建了一个函数,其中包含从后端检索值的ajax调用

getData: function () {
$.ajax({
    url: "http://demos.telerik.com/kendo-ui/service/Products", //replace this with your url to get the data from backend
    type: "GET",
    dataType: "jsonp" // replace this with the type suit your need maybe json or etc (just use this as example to fire the success event

}).success(function (data) {
    //asumme this dummy data is the data coming from backend
    var dummyData = {
        textValue: "new Text value",
        textareaValue: "new Textarea value",
        checkboxValue: true,
        radioValue: "new Apple",
        checkboxListValue: ["Banana"],
        multipleSelectValue: ["Banana"],
        fruits: ["Apple", "Banana", "Orange"],
        selectValue: "Orange"
    };
    //set the viewModel value with the data coming from backend
    viewModel.set("textValue", dummyData.textValue);
    viewModel.set("textareaValue", dummyData.textareaValue);
    viewModel.set("checkboxValue", dummyData.checkboxValue);
    viewModel.set("radioValue", dummyData.radioValue);
    viewModel.set("checkboxListValue", dummyData.checkboxListValue);
    viewModel.set("multipleSelectValue", dummyData.multipleSelectValue);
    viewModel.set("selectValue", dummyData.selectValue);

    //after you set the value, because the viewModel already bind with the component/value of the kendo widget on the HTML side the textbox/dropdown/checkbox will automatically updated
});
}

我还在html上创建了一个按钮来触发getData函数

<tr>
    <td><span data-role="button" data-bind="events:{click:getData}" />
         <h4>Click this to do ajax call </h4>
    </td>
</tr>

单击此按钮进行ajax调用

看到这一点,单击按钮,您将看到从(文本值到新文本值)更新的数据

在您第一次链接到kendo dojo时,在
视图模型中
我创建了一个包含从后端检索值的ajax调用的函数

getData: function () {
$.ajax({
    url: "http://demos.telerik.com/kendo-ui/service/Products", //replace this with your url to get the data from backend
    type: "GET",
    dataType: "jsonp" // replace this with the type suit your need maybe json or etc (just use this as example to fire the success event

}).success(function (data) {
    //asumme this dummy data is the data coming from backend
    var dummyData = {
        textValue: "new Text value",
        textareaValue: "new Textarea value",
        checkboxValue: true,
        radioValue: "new Apple",
        checkboxListValue: ["Banana"],
        multipleSelectValue: ["Banana"],
        fruits: ["Apple", "Banana", "Orange"],
        selectValue: "Orange"
    };
    //set the viewModel value with the data coming from backend
    viewModel.set("textValue", dummyData.textValue);
    viewModel.set("textareaValue", dummyData.textareaValue);
    viewModel.set("checkboxValue", dummyData.checkboxValue);
    viewModel.set("radioValue", dummyData.radioValue);
    viewModel.set("checkboxListValue", dummyData.checkboxListValue);
    viewModel.set("multipleSelectValue", dummyData.multipleSelectValue);
    viewModel.set("selectValue", dummyData.selectValue);

    //after you set the value, because the viewModel already bind with the component/value of the kendo widget on the HTML side the textbox/dropdown/checkbox will automatically updated
});
}

我还在html上创建了一个按钮来触发getData函数

<tr>
    <td><span data-role="button" data-bind="events:{click:getData}" />
         <h4>Click this to do ajax call </h4>
    </td>
</tr>

单击此按钮进行ajax调用

看到这一点,单击按钮,您将看到从(文本值到新文本值)更新的数据

在您第一次链接到kendo dojo时,在
视图模型中
我创建了一个包含从后端检索值的ajax调用的函数

getData: function () {
$.ajax({
    url: "http://demos.telerik.com/kendo-ui/service/Products", //replace this with your url to get the data from backend
    type: "GET",
    dataType: "jsonp" // replace this with the type suit your need maybe json or etc (just use this as example to fire the success event

}).success(function (data) {
    //asumme this dummy data is the data coming from backend
    var dummyData = {
        textValue: "new Text value",
        textareaValue: "new Textarea value",
        checkboxValue: true,
        radioValue: "new Apple",
        checkboxListValue: ["Banana"],
        multipleSelectValue: ["Banana"],
        fruits: ["Apple", "Banana", "Orange"],
        selectValue: "Orange"
    };
    //set the viewModel value with the data coming from backend
    viewModel.set("textValue", dummyData.textValue);
    viewModel.set("textareaValue", dummyData.textareaValue);
    viewModel.set("checkboxValue", dummyData.checkboxValue);
    viewModel.set("radioValue", dummyData.radioValue);
    viewModel.set("checkboxListValue", dummyData.checkboxListValue);
    viewModel.set("multipleSelectValue", dummyData.multipleSelectValue);
    viewModel.set("selectValue", dummyData.selectValue);

    //after you set the value, because the viewModel already bind with the component/value of the kendo widget on the HTML side the textbox/dropdown/checkbox will automatically updated
});
}

我还在html上创建了一个按钮来触发getData函数

<tr>
    <td><span data-role="button" data-bind="events:{click:getData}" />
         <h4>Click this to do ajax call </h4>
    </td>
</tr>

单击此按钮进行ajax调用

看到这一点,单击按钮,您将看到从(文本值到新文本值)更新的数据

在您第一次链接到kendo dojo时,在
视图模型中
我创建了一个包含从后端检索值的ajax调用的函数

getData: function () {
$.ajax({
    url: "http://demos.telerik.com/kendo-ui/service/Products", //replace this with your url to get the data from backend
    type: "GET",
    dataType: "jsonp" // replace this with the type suit your need maybe json or etc (just use this as example to fire the success event

}).success(function (data) {
    //asumme this dummy data is the data coming from backend
    var dummyData = {
        textValue: "new Text value",
        textareaValue: "new Textarea value",
        checkboxValue: true,
        radioValue: "new Apple",
        checkboxListValue: ["Banana"],
        multipleSelectValue: ["Banana"],
        fruits: ["Apple", "Banana", "Orange"],
        selectValue: "Orange"
    };
    //set the viewModel value with the data coming from backend
    viewModel.set("textValue", dummyData.textValue);
    viewModel.set("textareaValue", dummyData.textareaValue);
    viewModel.set("checkboxValue", dummyData.checkboxValue);
    viewModel.set("radioValue", dummyData.radioValue);
    viewModel.set("checkboxListValue", dummyData.checkboxListValue);
    viewModel.set("multipleSelectValue", dummyData.multipleSelectValue);
    viewModel.set("selectValue", dummyData.selectValue);

    //after you set the value, because the viewModel already bind with the component/value of the kendo widget on the HTML side the textbox/dropdown/checkbox will automatically updated
});
}

我还在html上创建了一个按钮来触发getData函数

<tr>
    <td><span data-role="button" data-bind="events:{click:getData}" />
         <h4>Click this to do ajax call </h4>
    </td>
</tr>

单击此按钮进行ajax调用


看到这一点,单击按钮,您将看到数据从(文本值更新为新文本值)

我可以看看您的一些代码吗?你是在尝试创建网格还是什么?我一直在尝试编写一个代码示例。我可能得等到星期一回来上班。我需要删除任何与公司相关的部分,但我应该能够得到一个例子。@machun回答你的问题:不,我有一堆网格示例。他们工作得很好。我需要数据源读取的结果来填充我的html元素,而不是填充我的网格行。数据源用于类似数组的数据,因此它对于绑定到网格、下拉列表,甚至只是无序列表html标记非常有用。这听起来像是在问如何使用数据源同时绑定到各种元素(输入、跨度、div等),而这不是它们的工作方式。在您的情况下,只需使用常规AJAX检索数据,然后将其绑定到viewmodel。@JFlox这就是我感到奇怪的原因,除了您只想从数据源获取第一个/最后一个/特定的数据我可以看到一些代码吗?你是在尝试创建网格还是什么?我一直在尝试编写一个代码示例。我可能得等到星期一回来上班。我需要删除任何与公司相关的部分,但我应该能够得到一个例子。@machun回答你的问题:不,我有一堆网格示例。他们工作得很好。我需要数据源读取的结果来填充我的html元素,而不是填充我的网格行。数据源用于类似数组的数据,因此它对于绑定到网格、下拉列表,甚至只是无序列表html标记非常有用。这听起来像是在问如何使用数据源同时绑定到各种元素(输入、跨度、div等),而这不是它们的工作方式。在您的情况下,只需使用常规AJAX检索数据,然后将其绑定到viewmodel。@JFlox这就是我感到奇怪的原因,除了您只想从数据源获取第一个/最后一个/特定的数据我可以看到一些代码吗?你是在尝试创建网格还是什么?我一直在尝试编写一个代码示例。我可能得等到星期一回来上班。我需要删除任何与公司相关的部分,但我应该能够得到一个例子。@machun回答你的问题:不,我有一堆网格示例。他们工作得很好。我需要数据源读取的结果来填充我的html元素,而不是填充我的网格行。数据源用于类似数组的数据,因此它对于绑定到网格、下拉列表,甚至只是无序列表html标记非常有用。这听起来像是在问如何使用数据源同时绑定到各种元素(输入、跨度、div等),而这不是它们的工作方式。在您的情况下,只需使用常规AJAX检索数据,然后将其绑定到viewmodel。@JFlox这就是我感到奇怪的原因,除了您只想从数据源获取第一个/最后一个/特定的数据我可以看到一些代码吗?你是在尝试创建网格还是什么?我一直在尝试编写一个代码示例。我可能得等到我