Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with an empty editoptions['value'] that generates a 'missing } after property list' error #8

Open
charl opened this issue Aug 17, 2009 · 0 comments

Comments

@charl
Copy link

charl commented Aug 17, 2009

When you try to display a jqGrid via your plugin for a model that has a an empty array as its value you get the jqGrid error above or you get a JavaScript error in the console complaining about a syntax error:

missing } after property list
[Break on this error] colModel:[{name:'id', index:...ype_id',editoptions:{value:"1:CPU"},widt

If one has a look at the coModel that your plugin returns you see the following syntax error:

--8<--
colModel:[{name:'id', index:'id',resizable:false,width:35},{name:'component_id', index:'component_id',editoptions:{value:"},width:96,editable:true,edittype:'select'},
--8<--

The editoptions key for the second column seems to have a single quote for the value key instead of two quotes (as it should have it the array of items was empty). The issue seems to stem from vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb::get_sub_options in the first 'if' conditional block where you check for :value.

Your code does not seem to cater for the fact that couple[1] may contain an empty array:

325 # Generate options for editable fields (value, data, width, maxvalue, cols, rows, ...)
326 def get_sub_options(editoptions)
327 options = "{"
328 editoptions.each do |couple|
329 if couple[0] == :value # :value => [[1, "Rails"], [2, "Ruby"], [3, "jQuery"]]
330 options << %Q/value:"/
331 couple[1].each do |v|
332 options << "#{v[0]}:#{v[1]};"
333 end
334 options.chop! << %Q/",/

Here is a diff of a possible fix inserted above line #334 (that works for me):

$ diff 2dc_jqgrid.rb 2dc_jqgrid.rb.new
333a334

      options << '"' unless options[-1] == '"'

396c397
< end

\ No newline at end of file

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant