How to return json for cfgrids

I am trying to return json for a cfgrid, but am having no luck. Is there something I need to add to this line of code?

event.renderData(data=results,type=“json”);

Regards,

Andrew Scott

http://www.andyscott.id.au/

hhmm, not that I know off Andrew, unless the cfgrid is expecting the data in a specific json format?
Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

You may want to check the case of the returned json.

Is cf expecting all “caps” in the json?
Is the json being produced all lower case?

I had a smiliar problem once - it took me over a day to figure out that my “case” was wrong. Once I made account for the “case” all worked as expected.

Don’t know if that’s the issue - just letting you know about my most recent experience with grids.

  • Russell

Hmmm, I’ll keep digging into it I think the only way to do this is use the normal ColdFusion method I think.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Ahh yes, I think you need to turn upper case on in render data for the json packets. CF has some weird stuff on their cfgrid
Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Mr. Scott,

Is there a way that we could look at this online? It would speed up the debugging and allow the possibility for a more accurate answer.

  • Russell

Wow, so formal. No it is not available online and it is a standard query converted to JSON, nothing more to it.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Mr. Scott,
In the morning I will post the code I used to get it to work for me. Maybe that can help you work through it - or at least, eliminate some avenues.

I had some issues using CB3 for json returns - but fixed them. Are you using CB3?

  • Russell

Thanks but I got it working, I had to convert the query into a struct that could then be converted to json.

Regards,

Andrew Scott

http://www.andyscott.id.au/

And please stop with the Mr. Scott business that is my father’s name.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Ok - Mr. ..... (oops) ... {old habits are hard to break} :slight_smile:

Ok, Scott.

I am sorry I didn't mention that before. I made an assumption that you were already doing that. It's the only way that I can return a "valid" json. When you said your json was correct - I did not pursue that avenue.

I run all my queries through a routine that converts it to a struct. then - that struct is "returned" as a json. (if that makes any sense).

At any rate, I'm glad that you were able to get it working.

By the way, I thought your name sounded familiar. So, I looked at your website. As soon as I saw your website - I knew who you were.

I want to personally thank you for having tutorials up. Recently (within the past 2 months), I have learned from the tutorials on your site. They helped me a lot. Keep up the good work.

And I will respect your choice of salutation.

- Russell

Yeah I made the mistake of thinking that the json in ColdBox was better than the json that I use, turns out that they are identical.

So once I did that I was up and running in no time, the stupid thing is I normally always do that and for some reason just didn’t even think of it.

Thank you so much for the kudos too.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Scott,

I would agree with you to an extent. In CB3, I use CB to mask my json requests.

Firebug can detect any "posts", "gets", json results and requests, so on and so forth.

But, with CB3 I am able to populate any data gird (cf, jQuery or any other ajax request), and hide the real service from Firebug. Thus, protecting my services from exposure. And as everyone knows, exposed services only invites hackers.

I wouldn't call CB3's handling of json better - just more secure.

CB3 protects my pages and my data. It's a good security layer. It leaves me free to quickly implement even tighter security, by taking care of the basics.

Every site that I make from now on WILL use the CB framework.

- Russell

How are you hiding the Ajax requests? All HTTP requests show up in firebug.

Regards,

Andrew Scott

http://www.andyscott.id.au/

:slight_smile:

Andrew,
The method I use is not documented. You are right about Firebug being able to see all http requests and results.

However, what I said was , " .... hide the real service from Firebug".

I probably need to make a tutorial on that - but, I don't have a blog site or a tutorial site. I'm not even sure I would be good at making a tutorial anyways.

However, since you are all set up for that and I know, personally, that you write good tutorials - I will show you what I did and you can test it, modify it, then write a tutorial on it.

Since it is a bit complicated, you will need to contact me, personally, so that I can walk you through and show you what I did.

Then you can verify if my services are protected. If, indeed they are, I will open the technique up for you to write a tutorial for the CB community.

I'm sure that my technique can be made better - maybe you can make it better and write a good tutorial on it.

"Are you game?"

- Russell