Announcement

Collapse
No announcement yet.

Get all entity data by entity ID

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get all entity data by entity ID

    Hello,

    I made an override of Quotes entity and made a relation with new entity named "Object". In data::function() method I want to collect all the information of entity "Object" records. So far I have ID's of those records only. I reach them by using this.model.attributes.objectnames. Is there a function something like getEntityById or do I have to write a PHP function to get it? How could I do so?

    At the moment I made a post ajax request to Quote controller and I get all the necessary information in that file, but it looks like a bad way to do so. Isn't it?

    Thanks.
    Last edited by The50; 12-28-2017, 04:54 PM.

  • #2
    Hello
    No, it's not a bad way

    Comment


    • #3
      Originally posted by tanya View Post
      Hello
      No, it's not a bad way
      There is another issue. I make an AJAX request like this https://pasteboard.co/H12qVsx.png and try to parse it into the template in data function. The problem is that AJAX requests takes a second to load and by the time page loads - there is no data in variable "objects". How could I make it load the data properly? I am trying to use the async option but it doesn't work.

      Comment


      • tanya
        tanya commented
        Editing a comment
        define objects in setup method

      • The50
        The50 commented
        Editing a comment
        Already tried that, it looks like this now https://pasteboard.co/H1Z96nZ.png Still I don't get any data in that console.log. If I do console.log on Ajax function .then method - data exists.

    • #4
      PHP Code:

      data
      : function () {
         return {
            
      objectListthis.objectList
         
      }
      },

      setup: function () {
        
      Dep.prototype.setup.call(this);
        
      this.wait(true);
        
      this.getAjaxPostRequest(...).then(function (result) {
           
      this.objectList result;
           
      this.wait(false);
        }.
      bind(ths));

      Comment


      • #5
        Thank you, it works!

        Comment

        Working...
        X