Kendo网格列显示/隐藏80多列的问题

我有一个大约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)); } }); 

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

我已经解决了这个问题。 我们使用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(); } 

它对你有用。