Skip to main content
added 351 characters in body
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

My advice is to keep the query in Javascript. Much simpler to keep all the logic in one place than try to route server logic into client code when you can avoid it.

You can, however, use a serialized array property.

public String mySerializedList { get; private set; }
public MyConstructor()
{
    mySerializedList = JSON.serialize([/*some query*/]);
}

Then in your client-side application you can parse it.

var objectArray = JSON.parse('{!JSINHTMLENCODE(mySerializedList)}');

My advice is to keep the query in Javascript. Much simpler to keep all the logic in one place than try to route server logic into client code when you can avoid it.

My advice is to keep the query in Javascript. Much simpler to keep all the logic in one place than try to route server logic into client code when you can avoid it.

You can, however, use a serialized array property.

public String mySerializedList { get; private set; }
public MyConstructor()
{
    mySerializedList = JSON.serialize([/*some query*/]);
}

Then in your client-side application you can parse it.

var objectArray = JSON.parse('{!JSINHTMLENCODE(mySerializedList)}');
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

My advice is to keep the query in Javascript. Much simpler to keep all the logic in one place than try to route server logic into client code when you can avoid it.