以编程方式向kendo网格添加一行而不刷新网格 [英] Add a row to kendo grid programmatically without grid refresh

查看:91
本文介绍了以编程方式向kendo网格添加一行而不刷新网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

StackOverflow Link



我的项目页面之一包含Kendo层次结构网格。内部网格包含3个组合框





当我从第3个组合框中选择一个项目时。新网格行将插入现有行的下方。



问题是在添加新行后,前3个组合框的选定值正在重置..



内网格代码





StackOverflow Link

One of my project page contains Kendo hierarchy grid. The inner grid contain 3 combo boxes


When I select an item form 3rd combo box. A new grid row will insert below the existing row.

The problem is after adding the new row the selected values of the first 3 combo boxes are resetting..

Inner Grid Code


 @(Html.Kendo().Grid<Clysar.Models.HierarchyData>()
            .Name("SubGridSecuritySection")
            .Columns(columns =>
            {
                columns.Bound(o => o.Area).ClientTemplate("<input id='areaCombo_#= UserId #' >").Width("25%");
                columns.Bound(o => o.Application).ClientTemplate("<input id='applicationCombo_#= UserId #'>").Width("25%");
                columns.Bound(o => o.UserLevel).ClientTemplate("<input id='userLevelCombo_#= UserId #'>").Width("25%");
            })
            .Events(events => events.DataBound("dataBound"))
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                        .Read(read => read.Action("BindHierarchy", "Security"))
            )
            .Sortable()
            .ToClientTemplate()
            
    )

function dataBound() {

        this.expandRow(this.tbody.find("tr.k-master-row").first());

        var dataSourceArea = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "GetAreaListForComboBox"
                }
            }
        });



        $.each($("[id^=userLevelCombo_]"), function () {
            element = this;
            $(this).kendoComboBox({
                dataSource: dataSourceUserLevel,
                dataTextField: "Value",
                dataValueField: "Key",
                filter: "contains",
                placeholder: "---Select---",
                change: function (e) {
                    debugger;
                    CreateNewGridRow();
                   
                }
               
            });
        });

    }

    function CreateNewGridRow() {
        var grid = $("#SubGridSecuritySection").data("kendoGrid");
        if (grid) {
            var dataSource = grid.dataSource;
            var total = dataSource.data().length;
            dataSource.insert(total, {});
        }
    }







如何解决这个问题..?




How to fix this issue..?

推荐答案

.each(


[id ^ = userLevelCombo _]), function (){
element = this ;


this )。kendoComboBox({
dataSource:dataSourceUserLevel,
dataTextField:
dataValueField:
filter: 包含
占位符: ---选择 - -
更改: function (e){
debugger ;
CreateNewGridRow();

}

});
});

}

function CreateNewGridRow(){
var grid =
(this).kendoComboBox({ dataSource: dataSourceUserLevel, dataTextField: "Value", dataValueField: "Key", filter: "contains", placeholder: "---Select---", change: function (e) { debugger; CreateNewGridRow(); } }); }); } function CreateNewGridRow() { var grid =


这篇关于以编程方式向kendo网格添加一行而不刷新网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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