将Json对象复制到视图中的Viewmodel [英] copy Json object to Viewmodel in view

查看:66
本文介绍了将Json对象复制到视图中的Viewmodel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我正在使用kendu UI网格来显示网格。

在网格中,我需要编辑和删除每一行的链接。



Hi Friends,
I am using kendu UI grid for displaying grid.
In Grid, I need edit and delete link for each row.

$("#grid").kendoGrid({
        dataSource: {
            transport: {
                read: "GetCompanyGroups",
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            },..............
{
            template: '<a class="edit btn btn-sm btn-default" href="javascript:EditCG(#=CompanyGroupId#);"><i class="icon-note"></i></a>',
            title: "Edit",
            lockable: false,
            width: 10
        }





如果我点击编辑,它将会调用以下函数并检索数据。





这是我的代码:



函数EditCG(id)

{

$ .ajax({

类型:GET,

url:EditCG,

数据:{Id:id},

cache:false,

成功:函数(响应) ){

$(#CompanyGroupName)。val(response.CompanyGroupName)

}

});

}



在我看来,我使用CompanyGroupVM作为视图模型。



我想复制回复对象为公司组VM



i想知道如何将Json对象复制到Viewmodel,还是有任何其他简单的功能可以在Kendo UI网格中进行编辑? />




问候,

Lalitha



if i click edit, it will call the below function and retrieve the data.


here is my code:

function EditCG(id)
{
$.ajax({
type: "GET",
url: "EditCG",
data: { Id: id },
cache: false,
success: function (response) {
$("#CompanyGroupName").val(response.CompanyGroupName)
}
});
}

in My view, I am using "CompanyGroupVM" as view model.

I want to copy the response object to "company group VM"

i want to know how to copy the Json object to Viewmodel or is there any other simple function for edit in Kendo UI grid?


Regards,
Lalitha

推荐答案

(#grid)。kendoGrid({
dataSource:{
transport:{
read:GetCompanyGroups,
contentType:application / json; charset = utf-8,
dataType:json
},..............
{
template:'< a = 编辑btn btn-sm btn-default href = javascript:EditCG(#= CompanyGroupId#); > < < span class =code-leadattribute> i class = icon-note > < / i > < / a > ',
title:编辑,
可锁定:false,
宽度:10
}
("#grid").kendoGrid({ dataSource: { transport: { read: "GetCompanyGroups", contentType: "application/json; charset=utf-8", dataType: "json" },.............. { template: '<a class="edit btn btn-sm btn-default" href="javascript:EditCG(#=CompanyGroupId#);"><i class="icon-note"></i></a>', title: "Edit", lockable: false, width: 10 }





如果我点击编辑,它将调用以下功能并检索数据。





这是我的代码:



功能EditCG(id)

{



if i click edit, it will call the below function and retrieve the data.


here is my code:

function EditCG(id)
{


.ajax({

类型:GET,

url:EditCG,

数据:{Id:id},

cache:false ,

成功:功能(响应){
.ajax({
type: "GET",
url: "EditCG",
data: { Id: id },
cache: false,
success: function (response) {


(#CompanyGroupName)。val(response.CompanyGroupName)

}

});

}



在我看来,我使用的是CompanyGroupVM查看模型。



我想将响应对象复制到公司组VM



i想要知道的要将Json对象复制到Viewmodel还是在Kendo UI网格中有任何其他简单的编辑功能?





问候,

Lalitha
("#CompanyGroupName").val(response.CompanyGroupName)
}
});
}

in My view, I am using "CompanyGroupVM" as view model.

I want to copy the response object to "company group VM"

i want to know how to copy the Json object to Viewmodel or is there any other simple function for edit in Kendo UI grid?


Regards,
Lalitha


这篇关于将Json对象复制到视图中的Viewmodel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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