@Diez - I had been using a wrapper class that just build dicts to pass
to templates w/o subclassing Widget.  I suppose I should start
learning how to code Widgets anyway.  Still, just for future
reference, lets say you just wanted to pass a boolean to JS using JSON
w/o using the Widget class.  It seems to me that since JSON is
basically just a collection of strings, you have to have something on
the JS side that would be dedicated to looping through all passed JSON
values and looking for some true/false string_flag
 Otherwise, no
matter what you do, JS can never tell a Boolean from a String just by
looking at the JSON.  Your example just ignores the JSON entirely and
manipulates the template directly.  Just wondering if there was
another way...

I don't fully understand that, but I fear you don't understand JSON, and it's usage (or lack of) for your use-case.

Instantiating the jqgrid has *nothing* todo with JSON. It's all about creating a javascript object, and pass that as options. JSON happens to be a subset of the javascript object literal notation - so you can (if you get in through a ajaj-request) simply eval it.

However, in your case, there is no JSON involved.

And you want to modify a jqgrid object afterwards, which has even less todo with JSON, it's pure & simple javascript.

 options.colModel[0].editable = true

can't be expressed in JSON. You can create a javascript-object (which incidentially is JSON, because it uses no expressions, just literals)

{"colModel" : [{"editable" : true}]}

which you could then pass as options-parameter if jqgrid allows that.

All in all I'd say your problem is simply creating javascript. I showed you one way, you can of course simply write it into the template if you prefer. And there is a toscawidgets js-abstraction which I rarely used, as it gave me errors in earlier versions, but it sort of makes you write python-code that emits the corresponding JS, with proper literals such as true and false.

http://toscawidgets.org/documentation/ToscaWidgets/modules/api.html#js-function


HTH,

Diez

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.


Reply via email to