I am using kendo grid's onDataBound
event to do something. Here's my jQuery code:
console.time('withoutnot');
jQuery(e.sender.dataSource._data).each(function (i, v) {
if (v.IsReadonly) {
e.sender.wrapper.find("tr[data-uid='" + v.uid + "'] .k-button")
.each(function (i, j) {
if (!jQuery(this).hasClass('k-grid-edit') && !jQuery(this).hasClass('k-grid-Desc')) {
jQuery(this).addClass('k-state-disabled').prop('disabled', true)
.prop('title', 'Readonly.');
}
});
}
});
console.timeEnd('withoutnot');
onDataBound
event gets raised once the grid has completed data-load from serverside.
My problem is that, because of 400 rows in the grid (without paging), it takes around 355ms
to 378ms
, which is still slower for me, because it causes visible performance lag in the grids load(readonly button effect).
How can I improve this code snippet even more? or is it the best I can go for?
NOTE: using native for
or jQuerys :not
(instead of those if conditions), proved disaster to me, load time scaled to 460ms
to 550ms
.
I am using jQuery 1.7.1
:not
as I'd expect it to be even with your filter and more elegant \$\endgroup\$e.sender.wrapper.find("tr[data-uid='" + v.uid + "'] .k-button:not(.k-grid-edit,.k-grid-Desc )")
. This would save me the need of that inner if condition.But Pseudo selectors are superbly slow \$\endgroup\$