how to display data returned by apex class

  • 1
  • Question
  • Updated 2 years ago
  • Answered
On click of record in skuid page table , i am calling Apex method via javascript. The Apex class is returning some data in the form of list(lets say related to some XYZ object). How can i display this data in my skuid page?

Is it possible to achieve so?
Photo of Sumeet Sangle

Sumeet Sangle

  • 452 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
See the "adoptRows" method in the skuid.model.Model object documentation.

Let's say that your Apex method returned a list of Accounts, and you want to incorporate these Accounts into a Skuid Model on the Account object. As long as this Model has all of the same fields requested on it via the Page Composer, all you should have to do in JavaScript to add these rows into your Skuid Model is something like this:

var mySkuidModel = skuid.$M('Accounts');

var myAccountRows = MyApexController.GetSomeAccounts();

console.log('Number of Accounts in Model BEFORE adoption: ' + mySkuidModel.getRows().length);

mySkuidModel.adoptRows(myAccountRows);

console.log('Number of Accounts in Model AFTER adoption: ' + mySkuidModel.getRows().length);
Photo of Sumeet Sangle

Sumeet Sangle

  • 452 Points 250 badge 2x thumb
Thanks Zach!