Context Factory?

  • 4
  • Question
  • Updated 1 year ago
  • Answered
  • (Edited)
Does Skuid have a context factory or something we could use for generating context? ie. from component to component
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 1 year ago

  • 4
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
We have the deck component and page include... I don't think I fully understand what you're asking for. Could you elaborate and possibly give an exact use case? 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
@Pat If you're building a custom component that does Deck-like functionality, where you're iterating over all rows in a Model, and you want to use skuid.actions.runActionsNode() and have it run the actions in context of the particular row that you care about, then just ensure that you are passing in the current row, e.g. your context can be as simple as this:


skuid.actions.runActionsNode(actionsNode, component, {
   model: model, 
   row: row,
});

If you're trying to do things with "selected Items" or "mass action" type capabilities, that's more complicated, but I could touch on that a bit more.

Hope that helps.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
If only I could intern in the Skuid engineering dept for a week. 
Photo of Andréas K.LeF.

Andréas K.LeF.

  • 96 Points 75 badge 2x thumb
Thanks Zach! that was all I needed. It was really much simpler than I thought...
Photo of Andréas K.LeF.

Andréas K.LeF.

  • 96 Points 75 badge 2x thumb
So I ended up with the following code

$a.runActionsNode(actionsNode, component, context ||
          {
              model: model,
              row: rowID ? model.getRowById(rowID) : null,
              initiatorId: initiatorId=event._GUID,
          }
Where the row attribute covers the case where context is row-based and the initiatorId is for component-based context cases
Photo of Andréas K.LeF.

Andréas K.LeF.

  • 96 Points 75 badge 2x thumb
So I ended up with the following code

$a.runActionsNode(actionsNode, component, context ||
          {
              model: model,
              row: rowID ? model.getRowById(rowID) : null,
              initiatorId: initiatorId=event._GUID,
          }
Where the row attribute covers the case where context is row-based and the initiatorId is for component-based context cases