search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to add search on child row?

Asked by Akhtar Raza
3 years ago.

I added the screenshot for this. I implemented the search on row from your tutorial it is working fine. But when I try to implement search on child row it is not working.

rowHeaderColumns: [
      { name: 'Function' },
      { name: 'Resources' }
    ],

On the First "name: function" I have further child data. Simply I want to search on any row and on any level.

Working Code:

onRowFilter: args => {
      console.log(args)
      if (args.row.name.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
        args.visible = false;
      }
}

I tried this also, But not working:

onRowFilter: args => {
      console.log(args)
      if (args.row.name1.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
        args.visible = false;
      }
}

Can you write code for me?
Have a look on my screen shot.

Answer posted by Dan Letecky [DayPilot]
3 years ago.

The args.row property holds a DayPilot.Row object and you can access the original resource data object (from resources[] array) using "data" property:

https://api.daypilot.org/daypilot-row-properties/

So it could look like this:

resources: [
  { name: "PostProd", name1: "additional value", id: 1 },
  // ...
],
onRowFilter: args => {
      console.log(args);
      if (args.row.data.name1.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
        args.visible = false;
      }
}
Comment posted by Akhtar Raza
3 years ago.

I already used this,
while using this name1 - error

TypeError: Cannot read properties of undefined (reading 'toLowerCase')
at DayPilot.Scheduler.onRowFilter (group-scheduler.component.ts:105)

I have two columns 1. Function and 2. Resource,
In the Function column, I have parent and child data, Parent search is working fine, But child search is not working

Comment posted by Akhtar Raza
3 years ago.

Could you solve this searching problem for me?

Comment posted by Shashi Dubey
3 years ago.

I'm also getting this problem. Dose any one have solution for this.

Comment posted by Akhtar Raza
3 years ago.

Will you give me some solution for this?

Comment posted by Dan Letecky [DayPilot]
3 years ago.

I recommend setting a breakpoint or logging the args object to console in onRowFilter to see why this is happening.

If you don't have the "name1" property defined for all rows, it will obviously complain that the object is undefined for these rows.

onRowFilter: args => {
      console.log(args);
      if (args.row.data.name1 && args.row.data.name1.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
        args.visible = false;
      }
}
Comment posted by Akhtar Raza
3 years ago.

name1 property defined in my code. When I'm using search with the only name property. It works very well for parent row not for a child. with name only in "console", I'm getting this. Have look at the screenshot.
Screenshot with the name property.

console.log("Args Date..",args)
if (args.row.name.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
args.visible = false;
}
https://ibb.co/3W2cwMP

When I'm using the name1 property.

console.log("Args Date..",args)
if (args.row.name1.toLowerCase().indexOf(args.filter.text.toLowerCase()) < 0) {
args.visible = false;
}
https://ibb.co/d2J1wj9

Comment posted by Akhtar Raza
3 years ago.

Hello, Thanks,
The last code works very perfectly. For 1 year I'm looking for this solution.

Thanks a lot.

Comment posted by Dan Letecky [DayPilot]
3 years ago.

Great, thanks for the update!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.