EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jega on January 09, 2025, 03:02:11 AM



Title: [SOLVED] Treegrid missing findby
Post by: jega on January 09, 2025, 03:02:11 AM
Hi.

In tree there is a findby, but not in treegrid.  :o


Title: Re: Treegrid missing findby
Post by: jarry on January 13, 2025, 07:18:28 PM
Here is the extended method that will be included into next version.
Code:
(function ($) {
function findBy(target, field, value) {
var state = $.data(target, 'treegrid');
var result = null;
$.easyui.forEach(state.data, true, function (node) {
if (node[field] == value) {
result = node;
return false;
}
});
return result;
}
$.extend($.fn.treegrid.methods, {
findBy: function (jq, param) {
return findBy(jq[0], param.field, param.value);
}
})
})(jQuery)


Title: Re: Treegrid missing findby
Post by: jega on January 15, 2025, 01:25:28 PM
Hi Jarry.

Nice, thanks

Jesper