4xmen / x-tree-select

Tree Select jQuery plugin
http://4xmen.ir
GNU General Public License v3.0
100 stars 26 forks source link

case-insensitive search #20

Open trading-developer opened 11 months ago

trading-developer commented 11 months ago

Hello! thank you for the work you have done. The plugin is very good, here is a small fix to make it even better, this is a case-insensitive search, I gave the entire method, but in fact there is only q.toLowerCase()

` this.searchShow = function (c, q, items) { var content = ''; var select = ''; if ($.xtsStore[c].selectablePrernt) { select = ''; } for (var ix in items) { var clsx = ' class="xli" '; var itm = items[ix]; if (itm[$.xtsStore[c].json.title].toString().toLowerCase().indexOf(q.toLowerCase()) !== -1 || itm[$.xtsStore[c].json.value].toString().indexOf(q.toLowerCase()) !== -1) { if (itm[$.xtsStore[c].json.child] != undefined && itm[$.xtsStore[c].json.child].length > 0) { clsx = ' class="xli xtsel-childer" '; content += '<li' + clsx + ' data-id="' + itm.idx + '" data-value="' + itm[$.xtsStore[c].json.value] + '">' + select + itm[$.xtsStore[c].json.title] + ''; content += $.xts.searchShow(c, q.toLowerCase(), itm[$.xtsStore[c].json.child]); } else { content += '<li' + clsx + ' data-id="' + itm.idx + '" data-value="' + itm[$.xtsStore[c].json.value] + '">' + itm[$.xtsStore[c].json.title] + ''; } } else { if (itm[$.xtsStore[c].json.child] != undefined && itm[$.xtsStore[c].json.child].length > 0) { content += $.xts.searchShow(c, q.toLowerCase(), itm[$.xtsStore[c].json.child]); } } } return content;

    }

`

A1Gard commented 11 months ago

You can do it with pull request bro