-3

I have this inside of a function:

var json = Ext.JSON.decode("{xtype: 'textfield',maxLength: 40}");

and it is fine. ExtJS allows that.
Then I have this inside another function:

var json = Ext.JSON.decode("{xtype:'combo',store: storeMercadosCombo, displayField: 'mercado',valueField:'id'}");

and ExtJS shows me:

Ext.Error: You're trying to decode an invalid JSON String: ...

Where is the error? How should Ext.JSON.decode be?
I'm using ExtJS 4.2.1

alexandre1985
  • 1,056
  • 3
  • 13
  • 31
  • 2
    You can't do that, JSON can't have references to functions/variables. – Evan Trimboli May 05 '16 at 20:30
  • @Alexander I'm trying to do my answer on this question http://stackoverflow.com/questions/7679364/extjs-4-rowediting-disable-edit-on-one-column-based-on-record/37057662#37057662, but with this new json – alexandre1985 May 05 '16 at 20:50
  • Well, instead of JSON.decode a string into an object, you should just use an object: `return {xtype: 'textfield',maxLength: 40}`... you don't gain anything by using JSON... – Alexander May 05 '16 at 20:55
  • @Alexander It doesn't work that way. I have tried – alexandre1985 May 05 '16 at 21:00
  • 1
    Using the object directly instead of JSON.decode will create exactly the same object at exactly the same time. Good luck with whatever you try, it won't work with JSON.decode as well. – Alexander May 05 '16 at 21:05
  • @Alexander I tried return {xtype: 'textfield', maxLength: 40} and it didn't work. I'm trying to disable a grid field from editing when using row_editing. As it is in the page that I gave you. But the answer on that page makes the column look funny and I don't want that – alexandre1985 May 05 '16 at 21:12

1 Answers1

1

Add quotes to storeMercadosCombo.

CD..
  • 72,281
  • 25
  • 154
  • 163
  • but if I had quotes to storeMercadosCombo it doesn't reconize it as a variable. It gives me an error that store is undefined... – alexandre1985 May 05 '16 at 19:26
  • 1
    @alexandre1985 Create storeId property inside your store and refer to it in your combo store property (as a string). – Miisha May 27 '16 at 13:12