javascript - Kendo grid column show/hide making issue with 80+ columns -
i have kendo grid around 80 columns. based on logic hiding/showing columns. first 20 columns static, , rest 60 depends on number of employees(eg:- if 20 employees 20 columns showing). deafault these 60 columns hidden. when loading data 40+ employees grid browser shows not responding. ie, takes time show/hide column.
please check code loading data
$.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 name header , 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)); } }); please let me know alternative solution same.
i have resolved issue. taking time when using hidecolumn() , showcolumn() methods of kendo grid. replaced normal jquery hide() , show() methods.
check below code
i have replaced
if (emplist[listindex].name.tostring() == "hidecolumn") { $('#grdemployees').data("kendogrid").hidecolumn(datafield); } else { $('#grdemployees').data("kendogrid").showcolumn(datafield); } with
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(); } it useful you.
Comments
Post a Comment