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()?
Announcement
Collapse
No announcement yet.
[Answered] vvOut embed
Collapse
X
-
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;
-
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
-
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
-
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.
i.e., {"string1":"hey, hey, hey","string2":"oy, oy, oy"}.
Comment
-
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
Comment