40464

ExtJS json store not populating

Question:

I've recently taken a dive into ExtJS by inheriting a web app written in 3.4. I've managed to create a store attached to a grid with no problem and have been able to bring up a PanelForm with data loaded from a call to a php page.

I have another json store defined which doesn't get populated when I call its load procedure and I'm wondering what I am missing.

The definition of the store is below:

var ImgStore = new Ext.data.JsonStore({ totalProperty: 'total' ,root: 'data' ,url : 'json/getProductImage/' ,fields : [{ name : 'img' },{ name : 'extn' }] });

My code to load the data is:

ImgStore.load({callback: function() {} ,params: {'ProductGUID': x} });

The code behind the URL is fine and the response in Firebug below:

{"success":true,"data":{"img":"iVBORw0KG...ggg==","extn":"png"}}

What I cannot understand is why the response comes back but the Store does not populate. I must be missing something; I just can't see what...

Does the Store have to be bound to another object? What I wanted to do was to read back the base64 encoded string and then show the image on screen (on either a panel, FormPanel or Container; not really sure of the best method really)

Any advice is greatly received.

Answer1:

Your store needs a model. The model needs to reflect the attributes that are then being returned in your JSON feed. Only then will the data show up in your store.

Answer2:

Everything looks fine, except for the url config aren't u missing the name of the file ? 'json/getProductImage/myfile.json'?

How are you validating store is not loaded by binding it to a grid? Because if so, store could be loading but not configuring grid properly might make u think store is not loaded, try console.log(store.getTotalCount())

Recommend

  • Store with json reader is not working
  • Where can I find a list of Worklight Error Codes
  • ExtJS Grid Paging: next button is disabled!
  • How to save image into sql-server using linq?
  • Extjs ComboBox doesn't pick the correct value when setValue is called
  • Pandas multi-index subtract from value based on value in other column
  • Multiple for loop iterators to unpack in Python [duplicate]
  • Flask-Restful error: “as_view” method not inherited
  • Inno Setup Search for specifc file on a CD, retrieve exact filepath and return value to [Files]-Sect
  • How to use HTTP Authentication with PHP and then run the entered data against a database?
  • Publishing HTML Field Control Converts Relative URL to Absolute URL
  • Number of nodes returned in MutationRecord.addedNodes nodelist (mutationObserver)
  • Visual Studio 2008 and JavaScript brackets formatting
  • Recommended way to remove events on destroy with jQuery UI Widget Factory
  • Differences between drawing an Ellipse in Android and Java
  • Best way to produce 'colour correct' raster from a PDF or PS with ghostscript
  • In java, how do you retrieve images from a jar file?
  • Mongodb update() vs. findAndModify() performace
  • composer dependency stating in doesn't have php-xsl
  • GitHub default README markup
  • Vigenere cipher not working
  • What is this strange character in chrome's resource css viewer?
  • INSERT EXEC Statement cannot be nested [duplicate]
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • Get used tables from sql query [duplicate]
  • SQL: Getting the physical size of a subset of a table
  • pip in virtualenv gets ConnectTimeoutError
  • pillow imaging ImportError
  • Select options in sencha touch is not working for android
  • Loading .coffee files via a view in Rails
  • How to use JavaScript to determine whether a file exists in a directory?
  • Marklogic : Query response time is very high
  • Create DicomImage from scratch using Dcmtk
  • File upload with ng-file-upload throwing error
  • Python: how to group similar lists together in a list of lists?
  • using HTMLImports.whenReady not working in chrome
  • Understanding cpu registers
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection
  • How to load view controller without button in storyboard?