Close All Drawers Action

  • 3
  • Question
  • Updated 6 months ago
  • Answered
Is there a way to close all drawers?  It'd be nice to have drawers close when another is opened.
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 4 years ago

  • 3
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
There is not a way to do this right now.  We are not yet ready to expose the API for interacting with the drawer programatically.  They are coming,  but not set enough for us to publicize... 
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Rob, Do you think the API will be exposed?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I think you'll be happy with our next release.  (Safe Harbor and all that, of course) 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Patch and Major release? Estimated ETA?
Photo of Jarrod Hinson

Jarrod Hinson

  • 2,310 Points 2k badge 2x thumb
I cannot wait for this to come, I have noticed some weird things happen with drawers because more than one are open at a time. Having a snippet to call before opening another drawer would be awesome!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Pro Tip:  Requerying a model will cause its drawers to close.  Of course, we'd encourage you to save models before you requery them in case stuff had been done.  
Photo of Jarrod Hinson

Jarrod Hinson

  • 2,310 Points 2k badge 2x thumb
Rob,
I usually use that method to make a close/cancel button but for the purposes of opening another drawer it doesn't work. I set up a row multi action button that queries the model first which closes the drawers but if the second action is to open a drawer it doesn't work the drawer won't open. is there a certain order that this works?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Jarrod,

I think this has to do with Query being an asynchronous action. The open drawer is probably actually running before the query completes. I'm not sure what the best way around that is.

Perhaps you can put the query in the 'before load' actions on the drawer, instead of in the action that opens the drawer?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You are right Jim. We'll add this idea to our backlog.. 
(Edited)
Photo of Jarrod Hinson

Jarrod Hinson

  • 2,310 Points 2k badge 2x thumb
Jim,
That makes sense. I tried that, it does the same thing when Query Model is on the before action on the drawer. It never opens the drawer.
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I use drawers a lot. Few tips to keep things running smoothly.
  1. Models to be used in drawers do not need to load on page load
  2. The action to use to open a drawer can be the stock Open Drawer action so long as you don't need to put the parent row into it's own model for use in other actions within the drawer.
  3. As Jim says, use "Before Load" to query the model used on the components in the drawer. Don't query completely. Query get more.
  4. Set the context of the components in the drawer to point to the parent row id.

2.


3.



4. 

Photo of Rajendra Rathore

Rajendra Rathore

  • 1,480 Points 1k badge 2x thumb
Yes that one much need feature in skuid.
Because let suppose when we open the drawer for task then it will show all the attachments related to task. So we are doing query on attachment that will get attachment for selected task.

But the issue is that when we open drawer for another task and for 1st task drawer is still open then it will replace the Task 2 attachments in Task 1 section attachments.

So there should be a way to close the all open drawer using action
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Your problem is solved by using the "Get More" behavior on the Query Model action that is bound to your row opening,  and making sure you have the context conditions set correctly for the attachments in your drawer.  Look at this tutorial:  http://help.skuid.com/m/supercharge-your-ui/l/269735-add-nested-rows-to-your-table-with-drawers
Photo of Rajendra Rathore

Rajendra Rathore

  • 1,480 Points 1k badge 2x thumb
Hi Rob,

But i already try Get More behavior.
But the issue is with Get more behavior is that :
1.) First i open drawer for Task 1 and it show me 2 attachment for Task 1.
2.) Then i opened the drawer for task 2 and task 2 have also have 2 attachment.

So now in both task 1 and task 2 drawer its showing me 4 -4 attachments.
But i want to see only attachment for current opened task drawer.

Hope that make sense?


Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
Set the Context as well.
Photo of Rajendra Rathore

Rajendra Rathore

  • 1,480 Points 1k badge 2x thumb
Hi Pat,

Yes after setting context its working as expected.

Thank You Both Pat! and Rob!

Thanks,
Raj
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hey friends.

Looks like some of the drawer-related functions are now exposed in the API. So, although this is UNDOCUMENTED, here's a snippet which when run immediately after an open/close drawers action in an action sequence, will close all the other open drawers, so you only have one open at a time.

// Run immediately after open/close drawer action to close other drawers.
var args = arguments[0],
thisID = args.item && args.item.drawers && args.item.drawers[0]._GUID,
tems = args.list.visibleItems,
drawer,
$ = skuid.$;
$.each(items,function(index,item){
drawer = item.drawers && item.drawers[0];
if (drawer && (drawer._GUID !== thisID) && drawer.isOpen) {
drawer.close();
}
});
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
Real quick and minor correction if anyone pastes this and gets an error:
tems = args.list.visibleItems,
This should be
items = args.list.visibleItems,
Otherwise it works great
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Hello, this sort of worked for me, except for a button at the bottom of the drawer:




Additionally, once closed I can't reopen the draw.

The problem I have is that button "I want to meet with this person" is using the model from the draw, but if two are opened at the same time it always uses the data from the latest opened draw. I can't set context on the button as far as I can see?
Photo of Laura Burnett

Laura Burnett

  • 588 Points 500 badge 2x thumb
Update: I was adding in the wrong place. When I added "run Skuid Javascript" to the action framework and then selected the relevant script, it worked!
Photo of Conlan O'Rourke

Conlan O'Rourke

  • 3,280 Points 3k badge 2x thumb
Matt's snippet works beautifully! Nonetheless, would love to have this as a declarative action