leovo2708 / ngx-treeview

An Angular treeview component with checkbox
MIT License
362 stars 337 forks source link

Parent nodes are not partially checked when child found by filter is selected #236

Open DmitriKurochkin opened 5 years ago

DmitriKurochkin commented 5 years ago

Hi, it seems like there is an issue when filter text is changed. Hierarchy tree is not updated correctly.

Below steps to reproduce in ngx-dropdown-treeview demo(https://leovo2708.github.io/ngx-treeview/#/components): Steps:

  1. Uncheck all selected items.
  2. Do search by 'Angular 2'
  3. Select 'Angular 2' child item
  4. Clear filter by selecting 'Angular 2' text and clicking on backspace or del button.
  5. Observe the tree.

Expected result: 'IT', 'Programming' and 'Frontend' items should have 'partially checked'('-') status

Actual result: 'IT', 'Programming' and 'Frontend' items have 'unchecked' status

Notes: if clear filter text 'Angular 2' letter by letter then hierarchy tree is updated correctly. I investigated that this.items in treeview.component.ts are not updated correctly. It looks like we should run correctChecked() for each item in the tree in updateFilterItems() function. As work around in our project we call correctChecked() for all our tree items on filterChange event.

ngx-treeview - Google Chrome 2019-09-12 11 46 28

TejasRadical commented 5 years ago

use this function in ts file your problem get resolve. vegetableCategory.correctChecked();