剑道格列显示/隐藏决策问题80+列(Kendo grid column show/hide maki

2019-10-23 01:39发布

我有大约80列的剑道网格。 基于一些逻辑,我隐藏/显示列。 首先20列是静态的,静止60取决于员工的数量(例如: - 如果20名员工则只有20列显示)。 通过deafault所有这些60列是隐藏的。 但与40多个员工将数据加载到网格浏览器显示没有响应。 也就是说,它需要时间来显示/隐藏列。

请检查我的代码加载数据

      $.ajax({
            type: "POST",
            url: '@Url.Action("GetData", "Employees")',
            dataType: "json",
            data: param,
            success: function (response) {
                if (response != null) {
                    var empList = response.Employees;
                    grid.dataSource.data([]);
                    grid.dataSource.data(response.Items);
                    //To change the name header and hide/show crew name column
                    if (empList != null) {
                        var listIndex = 0;                        
                        $('#grdEmployees th[coltype]').each(function (i) {                         
                            if ($(this).data().title == "HideColumn") {
                                var dataField = "Crew" + (listIndex + 1);
                                $("#grdEmployees thead [data-field=" + dataField + "] .k-link").html(empList[listIndex].Name.toString());                                    

                                if (empList[listIndex].Name.toString() == "HideColumn") {                                   
                                    $('#grdEmployees').data("kendoGrid").hideColumn(dataField);

                                } else {                                    
                                    $('#grdEmployees').data("kendoGrid").showColumn(dataField);  
                                }


                                listIndex++;
                            }
                        });
                    }                   
                }               
            },
            error: function (err) {
                console.log(JSON.stringify(err));                
            }
        });

请让我知道任何替代解决方案这样做。

Answer 1:

我已经解决了这个问题。 它需要时间,当我们使用hideColumn()showColumn()剑道电网的方法。 所以,我只是正常的jQuery代替它hide()show()方法。

检查下面的代码

我已经取代

if (empList[listIndex].Name.toString() == "HideColumn") {                                   
    $('#grdEmployees').data("kendoGrid").hideColumn(dataField);
} else {   
    $('#grdEmployees').data("kendoGrid").showColumn(dataField);  
}  

var colIdx = $(this).index() + 1; 
if (crewNameList[listIndex].Name.toString() == "HideColumn") {                        
    $("#grdEmployees table th:nth-child(" + colIdx + "),td:nth-child(" + (colIdx) + "),col:nth-child(" + (colIdx-1) + ")").hide();                      
} else {                        
    $("#grdEmployees table th:nth-child(" + (colIdx) + "),td:nth-child(" + (colIdx) + "),col:nth-child(" + (colIdx-1) + ")").show();                           
}

这将是对你有用。



文章来源: Kendo grid column show/hide making issue with 80+ columns