Filtering issue on a dGrid Tree grid

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Filtering issue on a dGrid Tree grid

Harry Devine

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Filtering issue on a dGrid Tree grid

Harry Devine

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude <[hidden email]> wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Filtering issue on a dGrid Tree grid

Harry Devine

But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude <[hidden email]> wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet : Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date : Tue, 9 May 2017 09:34:16 -0400 (EDT)
De : Harry Devine [hidden email]
Répondre à : [hidden email]
Pour : [hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Portion de message joint (300 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Harry Devine

OK, I'm obviously missing something.  By doing that, I still see all tree grid items initially, however, I don't see any children when I click on the arrow.  When I try to filter out based on month, instead of setting the collection to a filter, I am setting the store's month property.  No change in the grid presentation.


I put my module up here:  https://gist.github.com/HDevine/2dc23a3315165475daa7ac4cec207947.  The main grid and store are defined in populateMainPage.  The function ShowQADueDialog sets the store's month property depending on what the user selected.  Perhaps you can see what I may be misunderstanding by seeing the code?


Thanks,

Harry

On May 9, 2017 at 9:57 AM Hujeux Jean-Claude <[hidden email]> wrote:

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet :Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date :Tue, 9 May 2017 09:34:16 -0400 (EDT)
De :Harry Devine [hidden email]
Répondre à :[hidden email]
Pour :[hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux
Seems to me this on line 45 is assgined to the global scope (Window object) whereas what you would need it for it to be assigned to mod.approachStore ... which is not defined yet.

I would try replacing lines 41..50:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        getChildren: function(object) {
          return this.root.filter({parent: this.getIdentity(object), month: this.month});
        },
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });

with:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });
      mod.approachStore.getChidren = function(object){
        return mod.approachStore.root.filter(({parent: this.getIdentity(object), month: mod.approachStore.month});
     });

jc

Le 09/05/2017 à 16:19, Harry Devine a écrit :

OK, I'm obviously missing something.  By doing that, I still see all tree grid items initially, however, I don't see any children when I click on the arrow.  When I try to filter out based on month, instead of setting the collection to a filter, I am setting the store's month property.  No change in the grid presentation.


I put my module up here:  https://gist.github.com/HDevine/2dc23a3315165475daa7ac4cec207947.  The main grid and store are defined in populateMainPage.  The function ShowQADueDialog sets the store's month property depending on what the user selected.  Perhaps you can see what I may be misunderstanding by seeing the code?


Thanks,

Harry

On May 9, 2017 at 9:57 AM Hujeux Jean-Claude [hidden email] wrote:

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet : Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date : Tue, 9 May 2017 09:34:16 -0400 (EDT)
De : Harry Devine [hidden email]
Répondre à : [hidden email]
Pour : [hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Harry Devine

Exact same symptoms as before.


Harry

On May 9, 2017 at 1:57 PM Hujeux Jean-Claude <[hidden email]> wrote:

Seems to me this on line 45 is assgined to the global scope (Window object) whereas what you would need it for it to be assigned to mod.approachStore ... which is not defined yet.

I would try replacing lines 41..50:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        getChildren: function(object) {
          return this.root.filter({parent: this.getIdentity(object), month: this.month});
        },
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });

with:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });
      mod.approachStore.getChidren = function(object){
        return mod.approachStore.root.filter(({parent: this.getIdentity(object), month: mod.approachStore.month});
     });

jc

Le 09/05/2017 à 16:19, Harry Devine a écrit :

OK, I'm obviously missing something.  By doing that, I still see all tree grid items initially, however, I don't see any children when I click on the arrow.  When I try to filter out based on month, instead of setting the collection to a filter, I am setting the store's month property.  No change in the grid presentation.


I put my module up here:  https://gist.github.com/HDevine/2dc23a3315165475daa7ac4cec207947.  The main grid and store are defined in populateMainPage.  The function ShowQADueDialog sets the store's month property depending on what the user selected.  Perhaps you can see what I may be misunderstanding by seeing the code?


Thanks,

Harry

On May 9, 2017 at 9:57 AM Hujeux Jean-Claude [hidden email] wrote:

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet :Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date :Tue, 9 May 2017 09:34:16 -0400 (EDT)
De :Harry Devine [hidden email]
Répondre à :[hidden email]
Pour :[hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux

Well,

Your best chance at this stage is to investigate what happens under the browser debugger,

jc


Le 09/05/2017 à 20:15, Harry Devine a écrit :

Exact same symptoms as before.


Harry

On May 9, 2017 at 1:57 PM Hujeux Jean-Claude [hidden email] wrote:

Seems to me this on line 45 is assgined to the global scope (Window object) whereas what you would need it for it to be assigned to mod.approachStore ... which is not defined yet.

I would try replacing lines 41..50:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        getChildren: function(object) {
          return this.root.filter({parent: this.getIdentity(object), month: this.month});
        },
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });

with:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });
      mod.approachStore.getChidren = function(object){
        return mod.approachStore.root.filter(({parent: this.getIdentity(object), month: mod.approachStore.month});
     });

jc

Le 09/05/2017 à 16:19, Harry Devine a écrit :

OK, I'm obviously missing something.  By doing that, I still see all tree grid items initially, however, I don't see any children when I click on the arrow.  When I try to filter out based on month, instead of setting the collection to a filter, I am setting the store's month property.  No change in the grid presentation.


I put my module up here:  https://gist.github.com/HDevine/2dc23a3315165475daa7ac4cec207947.  The main grid and store are defined in populateMainPage.  The function ShowQADueDialog sets the store's month property depending on what the user selected.  Perhaps you can see what I may be misunderstanding by seeing the code?


Thanks,

Harry

On May 9, 2017 at 9:57 AM Hujeux Jean-Claude [hidden email] wrote:

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet : Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date : Tue, 9 May 2017 09:34:16 -0400 (EDT)
De : Harry Devine [hidden email]
Répondre à : [hidden email]
Pour : [hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Harry Devine

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry

On May 9, 2017 at 5:32 PM Hujeux Jean-Claude <[hidden email]> wrote:

Well,

Your best chance at this stage is to investigate what happens under the browser debugger,

jc


Le 09/05/2017 à 20:15, Harry Devine a écrit :

Exact same symptoms as before.


Harry

On May 9, 2017 at 1:57 PM Hujeux Jean-Claude [hidden email] wrote:

Seems to me this on line 45 is assgined to the global scope (Window object) whereas what you would need it for it to be assigned to mod.approachStore ... which is not defined yet.

I would try replacing lines 41..50:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        getChildren: function(object) {
          return this.root.filter({parent: this.getIdentity(object), month: this.month});
        },
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });

with:

      mod.approachStore = new TreeMemory({target: "msawGetApproachControls.php", idProperty: 'id',
        month: null,
        mayHaveChildren: function(item) {
          return item.hasChildren == true;
        }
      });
      mod.approachStore.getChidren = function(object){
        return mod.approachStore.root.filter(({parent: this.getIdentity(object), month: mod.approachStore.month});
     });

jc

Le 09/05/2017 à 16:19, Harry Devine a écrit :

OK, I'm obviously missing something.  By doing that, I still see all tree grid items initially, however, I don't see any children when I click on the arrow.  When I try to filter out based on month, instead of setting the collection to a filter, I am setting the store's month property.  No change in the grid presentation.


I put my module up here:  https://gist.github.com/HDevine/2dc23a3315165475daa7ac4cec207947.  The main grid and store are defined in populateMainPage.  The function ShowQADueDialog sets the store's month property depending on what the user selected.  Perhaps you can see what I may be misunderstanding by seeing the code?


Thanks,

Harry

On May 9, 2017 at 9:57 AM Hujeux Jean-Claude [hidden email] wrote:

You just need to make inMonth visible from inside getChildren, for example you can make it it a property of the dstore:

        store.inMonth = inMonth;

        ....

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: this.inMonth});
        }

jc

-------- Message transféré --------
Sujet :Re: [Dojo-interest] Filtering issue on a dGrid Tree grid
Date :Tue, 9 May 2017 09:34:16 -0400 (EDT)
De :Harry Devine [hidden email]
Répondre à :[hidden email]
Pour :[hidden email]


But this is more of an "on demand" or "on the fly" filter.  I have a button that the use clicks and it brings up a dialog where they select the month they want to filter on.  They select it and the filter gets applied as follows:


grid.set('collection', store.filter({month: intMonth}));


Later, they may want to filter on January for example.  I don't understand how to take this logic and apply it to the getChildren function.  The getChildren works great when the grid is initially loaded and ALL items are displayed.  But showing only a subset of items is where I'm stuck.  Any ideas on how to get that to work?


Thanks,

Harry

On May 9, 2017 at 8:30 AM Hujeux Jean-Claude [hidden email] wrote:

Harry,

As I understand it, it's all about having the 3 functions mayHaveChildren, getRootCollection & getChildren correct, and making sure you set the grid's collection: grid.set('collection',store.getRootCollection()) every time required  (initially, and every time the root collection changes, for example if its filters change).

If you see all data as a single grid and not a tree grid, then this is most probably because your getRootCollection() function returns all these data, i.e. it does not filter out the children, when your statement grid.set(collection', store.rootCollection()) (or equivalent) is executed.

Back on my suggestion for getChildren, and taking dstore/Tree as a starting point, if your parents do not have a month value and your children have, and you need to filter children based on their month value, you can simply modify getChildren from:

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object) });
        }
to

        getChildren: function (object) {
            return this.root.filter({ parent: this.getIdentity(object), month: 'april' });
        }
jc


Le 08/05/2017 à 21:28, Harry Devine a écrit :

I took a different GUI approach, but decided to go back to this one and see if I could make it work based on what you suggested.  I have some subtle differences between now and my original question.  I'll try my best to detail them here:


1) when I filter on a month, such as April, I see all of the data now as a single grid, NOT a tree grid.  I can see the parent items now, but I expected them to be shown as a tree as the initial full treegrid was displayed.  Not sure why.

2) I made no changes to getChildren yet, as I don't know WHAT to make the function do base on your suggestion below.  Is there 1 parameter set for the full tree sent to getChildren and another sent when filtering?

3) I also have filter that lets me filter on Site Name, i.e ZAN.  When I apply this filter, the grid is redrawn.  The first item is the tree parent with that site name.  However, the next X lines that are shown are the child items themselves OUTSIDE of the tree presentation.  When I expand the tree expando next to the first item, then the extraneous child items are removed and shown in the proper tree grid.


I thought about putting up a screen capture or 2 to illustrate, but I wasn't sure if they would make the message to the list  too large, so I opted out of that.  If you need any code or screen shots, let me know how I should provide them.  I could put code up onto Gist.


Thanks,

Harry

On May 3, 2017 at 1:17 PM Hujeux Jean-Claude [hidden email] wrote:

Harry,

You apply the filter to the dgrid collection, isn't it ? Then only those parent items that match the filter will show-up: if they do not have month = april they won't show-up.

If this is your situation, have you tried applying the filter inside the getChildren function ?

jc
Le 01/05/2017 à 20:08, Harry Devine a écrit :

I have a grid working with the Tree mixin/extension configured, along with a dStore Tree store feeding it.  Looks normal.  However, if I try to filter the grid to show a certain pieces of information in the child items (in this case, all months that are April for example), I see the child items listed, but the parent items are not shown.  Resetting the grid to show all items again shows up properly.  


I wanted to try and make a JSFiddle to display this issue, but I'm not sure how to configure it for dGrid and dStore.  So if anyone has any ideas on 1) how to have the parent items show up when I filter the grid on a child item, and 2) how to configure JSFiddle to show/use a dGrid and dStore, I'd appreciate it.


Thanks,

Harry





 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux
I can't help on the fiddle side, I transferred your file to my environment and had it to work as expected once I fixed the following bugs:
  • require statement:
    • missing "dojo/_base/declare"
    • "dgrid/Pagination" should be "dgrid/extensions/Pagination" (I removed it for my test)
  • line 63: mod.approachStore, should just be approachStore
  • line 75: "resetButton" should be "filterButton"
Provided those fixes, it works as expected:
  • when you click on the arrows, children appear
  • when you click on FilterGrid, everything disappears: this is because you apply the filter {month: 3} on the collection, and your 3 root items (id 0, 1 and 2) don't have a month property, so they are filtered out.

To fix this, you need to move the month filter to getChildren. You also need to refresh the grid in your buttons onClick function. Below a code with those changes which is fully functional in my environment, you should only need to change for the location where your dojo environment is located (lines 6, 7, 17, 18 and 23),

Rgds,

jc


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site","hasChildren":true},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(item) {
                return item.hasChildren == true;
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    //msawGrid.set('collection', approachStore.filter({month: 3}));
                    monthFilter = "3";
                    msawGrid.refresh();
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        //msawGrid.set('collection', approachStore.filter(o=>o.parent == undefined));
                        monthFilter = false;
                        msawGrid.refresh();
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

Le 12/05/2017 à 17:05, Harry Devine a écrit :

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry




--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Harry Devine

I updated the JSFiddle based on your suggestions (the errors were typos since I didn't copy/paste from my development environment), and while its closer, it still doesn't look as I think it should.   When I apply the filter (which I know in my test data is Site2 and Site3), I can expand the parent and see the data.  But Site1 is still present, and expanding the expando icon looks like it tries to open but doesn't show anything.  I know this is because the month child filter doesn't match, but I know that my users will get confused on why Site1 is there if it doesn't match the filter.  Is there any way to have the parent items that do NOT match the filter not even be displayed in the grid?


The updated JSFiddle is here:  https://jsfiddle.net/hdevine/qsxsuhkz/4/


Thanks,

Harry

On May 13, 2017 at 9:46 AM Hujeux Jean-Claude <[hidden email]> wrote:

I can't help on the fiddle side, I transferred your file to my environment and had it to work as expected once I fixed the following bugs:
  • require statement:
    • missing "dojo/_base/declare"
    • "dgrid/Pagination" should be "dgrid/extensions/Pagination" (I removed it for my test)
  • line 63: mod.approachStore, should just be approachStore
  • line 75: "resetButton" should be "filterButton"
Provided those fixes, it works as expected:
  • when you click on the arrows, children appear
  • when you click on FilterGrid, everything disappears: this is because you apply the filter {month: 3} on the collection, and your 3 root items (id 0, 1 and 2) don't have a month property, so they are filtered out.

To fix this, you need to move the month filter to getChildren. You also need to refresh the grid in your buttons onClick function. Below a code with those changes which is fully functional in my environment, you should only need to change for the location where your dojo environment is located (lines 6, 7, 17, 18 and 23),

Rgds,

jc


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site","hasChildren":true},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(item) {
                return item.hasChildren == true;
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    //msawGrid.set('collection', approachStore.filter({month: 3}));
                    monthFilter = "3";
                    msawGrid.refresh();
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        //msawGrid.set('collection', approachStore.filter(o=>o.parent == undefined));
                        monthFilter = false;
                        msawGrid.refresh();
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

Le 12/05/2017 à 17:05, Harry Devine a écrit :

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux

The expando is still there for site1 due to fact your mayHaveChildren() function always return true for site1 (and site2 and site3).

Changing it for example to:

            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).filter({parent: object.id}).fetchSync().length > 0;
            }

will make it return false when a site has no children, if you remove the "hasChildren": true from the site rows data, and then the expando won't show-up when there is no children. Still the site row will display

If you really want the site row not to show up when it has no children, then the answer is to reactivate the  set('collection', something) statement in your onClick functions, where something is the root collection (approachStore.filter(o=>o.parent == undefined)), additionnally filtered out for rows with no children for the new monthFilter value

jc


Le 15/05/2017 à 14:41, Harry Devine a écrit :

I updated the JSFiddle based on your suggestions (the errors were typos since I didn't copy/paste from my development environment), and while its closer, it still doesn't look as I think it should.   When I apply the filter (which I know in my test data is Site2 and Site3), I can expand the parent and see the data.  But Site1 is still present, and expanding the expando icon looks like it tries to open but doesn't show anything.  I know this is because the month child filter doesn't match, but I know that my users will get confused on why Site1 is there if it doesn't match the filter.  Is there any way to have the parent items that do NOT match the filter not even be displayed in the grid?


The updated JSFiddle is here:  https://jsfiddle.net/hdevine/qsxsuhkz/4/


Thanks,

Harry

On May 13, 2017 at 9:46 AM Hujeux Jean-Claude [hidden email] wrote:

I can't help on the fiddle side, I transferred your file to my environment and had it to work as expected once I fixed the following bugs:
  • require statement:
    • missing "dojo/_base/declare"
    • "dgrid/Pagination" should be "dgrid/extensions/Pagination" (I removed it for my test)
  • line 63: mod.approachStore, should just be approachStore
  • line 75: "resetButton" should be "filterButton"
Provided those fixes, it works as expected:
  • when you click on the arrows, children appear
  • when you click on FilterGrid, everything disappears: this is because you apply the filter {month: 3} on the collection, and your 3 root items (id 0, 1 and 2) don't have a month property, so they are filtered out.

To fix this, you need to move the month filter to getChildren. You also need to refresh the grid in your buttons onClick function. Below a code with those changes which is fully functional in my environment, you should only need to change for the location where your dojo environment is located (lines 6, 7, 17, 18 and 23),

Rgds,

jc


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site","hasChildren":true},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(item) {
                return item.hasChildren == true;
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    //msawGrid.set('collection', approachStore.filter({month: 3}));
                    monthFilter = "3";
                    msawGrid.refresh();
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        //msawGrid.set('collection', approachStore.filter(o=>o.parent == undefined));
                        monthFilter = false;
                        msawGrid.refresh();
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

Le 12/05/2017 à 17:05, Harry Devine a écrit :

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Harry Devine

I just tried what you suggested and it reacts the same way at it always has:  https://jsfiddle.net/hdevine/qsxsuhkz/6/.


Can you expound on the last section about filtering out for rows with no children?  HOW do we know if a row has no children based on the filter at that point?


Thanks,

Harry

On May 15, 2017 at 3:53 PM Hujeux Jean-Claude <[hidden email]> wrote:

The expando is still there for site1 due to fact your mayHaveChildren() function always return true for site1 (and site2 and site3).

Changing it for example to:

            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).filter({parent: object.id}).fetchSync().length > 0;
            }

will make it return false when a site has no children, if you remove the "hasChildren": true from the site rows data, and then the expando won't show-up when there is no children. Still the site row will display

If you really want the site row not to show up when it has no children, then the answer is to reactivate the  set('collection', something) statement in your onClick functions, where something is the root collection (approachStore.filter(o=>o.parent == undefined)), additionnally filtered out for rows with no children for the new monthFilter value

jc


Le 15/05/2017 à 14:41, Harry Devine a écrit :

I updated the JSFiddle based on your suggestions (the errors were typos since I didn't copy/paste from my development environment), and while its closer, it still doesn't look as I think it should.   When I apply the filter (which I know in my test data is Site2 and Site3), I can expand the parent and see the data.  But Site1 is still present, and expanding the expando icon looks like it tries to open but doesn't show anything.  I know this is because the month child filter doesn't match, but I know that my users will get confused on why Site1 is there if it doesn't match the filter.  Is there any way to have the parent items that do NOT match the filter not even be displayed in the grid?


The updated JSFiddle is here:  https://jsfiddle.net/hdevine/qsxsuhkz/4/


Thanks,

Harry

On May 13, 2017 at 9:46 AM Hujeux Jean-Claude [hidden email] wrote:

I can't help on the fiddle side, I transferred your file to my environment and had it to work as expected once I fixed the following bugs:
  • require statement:
    • missing "dojo/_base/declare"
    • "dgrid/Pagination" should be "dgrid/extensions/Pagination" (I removed it for my test)
  • line 63: mod.approachStore, should just be approachStore
  • line 75: "resetButton" should be "filterButton"
Provided those fixes, it works as expected:
  • when you click on the arrows, children appear
  • when you click on FilterGrid, everything disappears: this is because you apply the filter {month: 3} on the collection, and your 3 root items (id 0, 1 and 2) don't have a month property, so they are filtered out.

To fix this, you need to move the month filter to getChildren. You also need to refresh the grid in your buttons onClick function. Below a code with those changes which is fully functional in my environment, you should only need to change for the location where your dojo environment is located (lines 6, 7, 17, 18 and 23),

Rgds,

jc


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site","hasChildren":true},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(item) {
                return item.hasChildren == true;
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    //msawGrid.set('collection', approachStore.filter({month: 3}));
                    monthFilter = "3";
                    msawGrid.refresh();
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        //msawGrid.set('collection', approachStore.filter(o=>o.parent == undefined));
                        monthFilter = false;
                        msawGrid.refresh();
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

Le 12/05/2017 à 17:05, Harry Devine a écrit :

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

jchujeux
In reply to this post by Jean-Claude Hujeux

Oops, made a mistake in mayHaveChildren, should have been

            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).fetchSync().length > 0;
            }

jc
Le 15/05/2017 à 21:53, Hujeux Jean-Claude a écrit :

The expando is still there for site1 due to fact your mayHaveChildren() function always return true for site1 (and site2 and site3).

Changing it for example to:

            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).filter({parent: object.id}).fetchSync().length > 0;
            }

will make it return false when a site has no children, if you remove the "hasChildren": true from the site rows data, and then the expando won't show-up when there is no children. Still the site row will display

If you really want the site row not to show up when it has no children, then the answer is to reactivate the  set('collection', something) statement in your onClick functions, where something is the root collection (approachStore.filter(o=>o.parent == undefined)), additionnally filtered out for rows with no children for the new monthFilter value

jc


Le 15/05/2017 à 14:41, Harry Devine a écrit :

I updated the JSFiddle based on your suggestions (the errors were typos since I didn't copy/paste from my development environment), and while its closer, it still doesn't look as I think it should.   When I apply the filter (which I know in my test data is Site2 and Site3), I can expand the parent and see the data.  But Site1 is still present, and expanding the expando icon looks like it tries to open but doesn't show anything.  I know this is because the month child filter doesn't match, but I know that my users will get confused on why Site1 is there if it doesn't match the filter.  Is there any way to have the parent items that do NOT match the filter not even be displayed in the grid?


The updated JSFiddle is here:  https://jsfiddle.net/hdevine/qsxsuhkz/4/


Thanks,

Harry

On May 13, 2017 at 9:46 AM Hujeux Jean-Claude [hidden email] wrote:

I can't help on the fiddle side, I transferred your file to my environment and had it to work as expected once I fixed the following bugs:
  • require statement:
    • missing "dojo/_base/declare"
    • "dgrid/Pagination" should be "dgrid/extensions/Pagination" (I removed it for my test)
  • line 63: mod.approachStore, should just be approachStore
  • line 75: "resetButton" should be "filterButton"
Provided those fixes, it works as expected:
  • when you click on the arrows, children appear
  • when you click on FilterGrid, everything disappears: this is because you apply the filter {month: 3} on the collection, and your 3 root items (id 0, 1 and 2) don't have a month property, so they are filtered out.

To fix this, you need to move the month filter to getChildren. You also need to refresh the grid in your buttons onClick function. Below a code with those changes which is fully functional in my environment, you should only need to change for the location where your dojo environment is located (lines 6, 7, 17, 18 and 23),

Rgds,

jc


<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site","hasChildren":true},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(item) {
                return item.hasChildren == true;
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    //msawGrid.set('collection', approachStore.filter({month: 3}));
                    monthFilter = "3";
                    msawGrid.refresh();
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        //msawGrid.set('collection', approachStore.filter(o=>o.parent == undefined));
                        monthFilter = false;
                        msawGrid.refresh();
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

Le 12/05/2017 à 17:05, Harry Devine a écrit :

I was working with Sitepen support on this, but their suggestions didn't work for me, and my support contract ran out.  So while we're in the process of renewing that, I figured I'd see if I could put up a test case on JSFiddle to show what my issue is.  That fiddle is here, although it doesn't load at the moment:  https://jsfiddle.net/hdevine/qsxsuhkz/.


I patterned the dGrid and dStore inclusions after what I found here:  http://jsfiddle.net/devpaul/3bxsxpvm/.  However, when my Fiddle loads, I get an error in the debugger that says" dojo.js.uncompressed.js:1893 Error: scriptError at f (dojo.js.uncompressed.js:106) at HTMLScriptElement.<anonymous> (dojo.js.uncompressed.js:1728)".


So, first question: can someone help get this jsfiddle to load?  Once that occurs, I should be able to show what my TreeGrid issue is.


Thanks,

Harry




 

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Re: Filtering issue on a dGrid Tree grid

Jean-Claude Hujeux
In reply to this post by Harry Devine

It reacts the same way because you did not remove "hasChildren":true from the site rows data (lines 29, 33 & 37 of your fiddle)

Below a source version that filters out root rows with no children:

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Harry Devine test</title>
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen">
        <link rel="stylesheet" href="dojo-release-1.12.2-src/dgrid/css/dgrid.css" media="screen">

    </head>
    <body class="claro">
        <div id="approachGrid"></div>
        <div id="filterButton"></div>
        <div id="resetButton"></div>
        <!-- load dojo and provide config via data attribute -->

        <script>var dojoConfig ={
                    baseUrl: "", isDebug: true, async: true,
                    packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"}, 
                               {"name": "dstore", "location": "dojo-release-1.12.2-src/dstore"}, {"name": "dgrid", "location": "dojo-release-1.12.2-src/dgrid"},
                    ],
                };
        </script>
        <script src="dojo-release-1.12.2-src/dojo/dojo.js"  data-dojo-config="async:true, parseOnLoad:true"></script>

        <script>


        require([
                "dojo/_base/declare",
                'dgrid/OnDemandGrid',
                'dgrid/Tree',
                //'dgrid/Pagination',
                'dstore/Memory',
                'dstore/Tree',
                'dijit/registry',
                'dijit/form/Button',
                'dojo/domReady!'
        ], function(declare, Grid, Tree/*, Pagination*/, Memory, TreeStore, registry, Button) {
            var msawGrid;
            var approachStore;
            var monthFilter;
            var StandardGrid = declare([Grid, Tree/*, Pagination*/]);
            var TreeMemory = declare([Memory, TreeStore]);

            var treeData = [
            {"id":0,"site":"Site1","type":"site"},
            {"id":1000,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-16","review":"Passed","comments":"Comment 1","month":"4"},
            {"id":1001,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-15","review":"Passed","comments":"Comment 2","month":"4"},
            {"id":1002,"site":"Site1","type":"review","parent":0,"lastqa":"27-APR-14","review":"Passed","comments":"Comment 3","month":"4"},
            {"id":1,"site":"Site2","type":"site","hasChildren":true},
            {"id":1003,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1004,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1005,"site":"Site2","type":"review","parent":1,"lastqa":"17-MAR-14","review":"Passed","comments":"Comment 3","month":"3"},
            {"id":2,"site":"Site3","type":"site","hasChildren":true},
            {"id":1006,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-16","review":"Passed","comments":"Comment 1","month":"3"},
            {"id":1007,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-15","review":"Passed","comments":"Comment 2","month":"3"},
            {"id":1008,"site":"Site3","type":"review","parent":2,"lastqa":"24-MAR-14","review":"Passed","comments":"Comment 3","month":"3"}
            ];

            approachStore = new TreeMemory({data: treeData, idProperty: 'id',
            getChildren: function(object) {
                return this.root.filter(monthFilter ? {parent: this.getIdentity(object), month: monthFilter} : {parent: this.getIdentity(object)});
            },
            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).fetch().then(function(data){
                    return data.length > 0;
                });
            }
            });

            /* Define the MSAW Approaches Grid  */
            if (!registry.byId("approachGrid")) {
                msawGrid = new StandardGrid({
                    columns: {
                        site:   {label: "LOCID", renderExpando: true, field: "site", width: 100 },
                        month: {label: "QA Annual Month", field: "month", width: 100 },
                        lastqa: {label: "Date", field: "lastqa"},
                        review: {label: "Pass/Fail", field: "review"},
                        comments: {label: "Comments", field: "comments"}
                    },
                    loadingMessage: "Loading MSAW Approaches...",
                    errorMessage: "Error loading MSAW Approaches...",
                    collection: approachStore.filter(o=>o.parent == undefined),
                    sort: [{property: "site", decending: true}],
                    rowsPerPage: 50
                }, "approachGrid");
            }

            var btnFilter = new Button({
                id: "filter_button",
                label: "Filter Grid",
                onClick: function() {
                    monthFilter = "3";
                    var fullRoot = approachStore.filter(o=>o.parent == undefined);
                    fullRoot.forEach(function(object){
                        if (approachStore.getChildren(object).fetchSync().length == 0){
                            object.hasChildren = false;
                        }else{
                            object.hasChildren = true;
                        }
                    });
                    msawGrid.set('collection', fullRoot.filter({hasChildren: true}));
                }
            }, "filterButton");

                var btnApproachesReset = new Button({
                    id: "reset_approaches_button",
                    label: "Reset Approaches Grid",
                    onClick: function() {
                        monthFilter = false;
                        var fullRoot = approachStore.filter(o=>o.parent == undefined);
                        fullRoot.forEach(function(object){
                            if (approachStore.getChildren(object).fetchSync().length == 0){
                                object.hasChildren = false;
                            }else{
                                object.hasChildren = true;
                            }
                        });
                        msawGrid.set('collection', fullRoot.filter({hasChildren: true}));
                    }
                }, "resetButton");

        });
        </script>
    </body>
</html>

jc
Le 15/05/2017 à 22:17, Harry Devine a écrit :

I just tried what you suggested and it reacts the same way at it always has:  https://jsfiddle.net/hdevine/qsxsuhkz/6/.


Can you expound on the last section about filtering out for rows with no children?  HOW do we know if a row has no children based on the filter at that point?


Thanks,

Harry

On May 15, 2017 at 3:53 PM Hujeux Jean-Claude [hidden email] wrote:

The expando is still there for site1 due to fact your mayHaveChildren() function always return true for site1 (and site2 and site3).

Changing it for example to:

            mayHaveChildren: function(object) {
                return 'hasChildren' in object ? object.hasChildren : this.getChildren(object).filter({parent: object.id}).fetchSync().length > 0;
            }

will make it return false when a site has no children, if you remove the "hasChildren": true from the site rows data, and then the expando won't show-up when there is no children. Still the site row will display

If you really want the site row not to show up when it has no children, then the answer is to reactivate the  set('collection', something) statement in your onClick functions, where something is the root collection (approachStore.filter(o=>o.parent == undefined)), additionnally filtered out for rows with no children for the new monthFilter value

jc


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest