• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[Answered] vvOut embed

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

  • [Answered] vvOut embed

    I always see embed just used to send Count of store records returned to be used by paging toolbar. Can that be used to send a JSON pair like a Total Amount or something for use when Store is loaded? If so, how would you reference it? Just define it as another property in the Reader section of the Proxy like totalProperty is? Then reference in code like Ext.getStore('mystore').totalAmount? Or Ext.getStore('mystore').totalAmount.getValue()?

  • #2
    Terry,

    You can place whatever you want in the embed, just needs to be valid JSON. Since ExtJs 6 you will need to set "keepRawData" with a value of true on the reader because starting with ExtJs 6 it doesn't keep the raw data unless that property is set to true.

    Example getting the raw data. Let's say the backend passed is isItemActive

    Code:
    var isItemActive = Ext.getStore('MyStore').getProxy().getReader().rawData.isItemActive;
    I personally stay away from going after a store after it's loaded to get other information outside the root "stores data". If a call from the backend is responding with items for a store and additional information I will just make a direct Ajax "Ext.Ajax.request" request then load the store directly with the data from it's response.

    Comment


    • #3
      Thanks Johnny. Why do you stay away from using embed that way? It seems like a natural for returning Total(s) of some numeric field in Store data? For example, I'm working on app for A/R. I want to show the total open receivables when I display the grid. Previously, I've made a completely separate server call triggered by the Load event to get totals. Seems like I could get these totals in the same server call I send Store back, then retrieve Total when Load event fires? Isn't that more efficient?

      I don't see anyway to get total on client side because I'm only sending a page at a time in the Store. This A/R Store has 2000+ records I need total from.

      Comment


      • #4
        I just tried this and it works fine. What Johnny said to get value was right on. On the RPG side, note you can only use one vvOut embed, you have to build your string of comma separated JSON pairs as needed. My initial try was another embed and then totalCount was gone for paging toolbar. Also have to modify loop sending out page at a time to read thru all records to get totals, another very minor change. Unless Johnny sees some gotcha I haven't seen yet, this is way better than a 2nd server call after Load and reading thru all these records again.

        One thing to note is your JSON data can not have comma in it because it is delimiter. You don't get the slick support like vvOut_json_pair where CNX lets you change the delimiter. This is raw JSON using embed.

        Comment


        • #5
          One thing to note is your JSON data can not have comma in it because it is delimiter. You don't get the slick support like vvOut_json_pair where CNX lets you change the delimiter. This is raw JSON using embed.
          Just to clarify, if you're placing a true JSON string into the vvOut.embed field then you can have as many commas as you want.

          i.e., {"string1":"hey, hey, hey","string2":"oy, oy, oy"}.

          Comment


          • #6
            Ahhh, thanks for clarifying surrounding in quotes will solve that, Robert. My app I was sending a number back (display use only) and was considering using %EDITC to put in commas and leading dollar sign. That's when I realized comma would cause problem. I ended up formatting on client side anyway with util.Format.usMoney.

            Comment

            Working...
            X