Link to home
Start Free TrialLog in
Avatar of jonatec
jonatecFlag for United Kingdom of Great Britain and Northern Ireland

asked on

jQuery Flexigrid Plugin - newbie help

Hi

Can anyone support my attempt to use this jQuery plugin, or know where I can go to get some decent support? I am using a .ashx generic handler and returning xml data but the data won't show up in the html page, any ideas please ????



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
		<title></title>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
		<script type="text/javascript" src="flexigrid/flexigrid.pack.js"></script>
		<link rel="Stylesheet" href="flexigrid/style.css" media="screen" />
		<script type="text/javascript">
				$("document").ready(function ()
				{
						$("#flex1").flexigrid({
								url: 'dac.ashx',
								dataType: 'xml',
								colModel: [
														{ display: 'ISO', name: 'iso', width: 40, sortable: true, align: 'center' },
														{ display: 'Name', name: 'name', width: 180, sortable: true, align: 'left' },
														{ display: 'Printable Name', name: 'printable_name', width: 120, sortable: true, align: 'left' },
														{ display: 'ISO3', name: 'iso3', width: 130, sortable: true, align: 'left', hide: true },
														{ display: 'Number Code', name: 'numcode', width: 80, sortable: true, align: 'right' }
														],								
								searchitems: [
														{ display: 'ISO', name: 'iso' },
														{ display: 'Name', name: 'name', isdefault: true }
														],
								sortname: "iso",
								sortorder: "asc",
								usepager: true,
								singleSelect: true,
								title: 'Countries',
								useRp: true,
								rp: 15,
								showTableToggleBtn: true,
								width: 700,
								height: 200
						});

				});

		</script>
</head>
<body>
		<table id='flex1'>
		</table>
</body>
</html>

-------------------------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace testproj
{
	public class dac : IHttpHandler
	{

		public void ProcessRequest(HttpContext context)
		{
			context.Response.ContentType = "text/HTML";

			string buf = string.Empty;
			buf += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
			buf += "<rows>";
			buf += "<page>1</page>";
			buf += "<total>2</total>";
			buf += "<row id='ZW'>";
			buf += "<cell>ZW</cell>";
			buf += "<cell>Zimbabwe</cell>";
			buf += "<cell>Zimbabwe</cell>";
			buf += "<cell>ZWE</cell>";
			buf += "<cell>716</cell>";
			buf += "</row>";
			buf += "<row id='ZM'>";
			buf += "<cell>ZM</cell>";
			buf += "<cell>Zambia</cell>";
			buf += "<cell>Zambia</cell>";
			buf += "<cell>ZMB</cell>";
			buf += "<cell>894</cell>";
			buf += "</row>";
			buf += "</rows>";

			context.Response.Write(buf);
		}

		public bool IsReusable
		{
			get
			{
				return false;
			}
		}
	}
}

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

Avatar of jonatec

ASKER

Ok thanks, but why as a dot net developer should I write a JSON function when it's easy to return xml from ADO.NET ? Question is can I return xml to the Flexigrid ?
I don't want to force you to return JSON or anything else, just to propose you the threads.
Avatar of jonatec

ASKER

The threads stated major on a JSON solution which I could just paste in and use. However I would like to return xml and process that in a Flexigrid, is that possible? ( The development documention at the Flexigrid web site is very sparse to say the least ).
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

.....
$("#flex1").flexigrid({
   url: 'WebService.asmx/HelloWorld',
....

Open in new window

Avatar of jonatec

ASKER

Great. Does the data type matter, ie...

context.Response.ContentType = "text/HTML";

should I change to text/xml  ?
it work fine for me without changing anything else in the webservice not you ?
Clipboard02.jpg
Avatar of jonatec

ASKER

Yeah, that's great thanks !

Point of discussion then before I close this...

Would you agree that JSON formatted data is unecessary when returning data from an ADO.NET dataset and that xml is better to use ?

>Point of discussion then before I close this...

You mean you won't give points before having the answer ?
Avatar of jonatec

ASKER

Thanks.
>Would you agree that JSON formatted data is unecessary when returning data from an ADO.NET dataset and that xml is better to use ?

Don't know about ADO.NET or another way to get data fastly.
Create a JSON object may be a long work with .NET but, as you know, for a large amount of data or a lot of requests you save a lot of bandwidth.
Point of view of the client side, most of time, it's easyest to use JSON data than XML data.

I saw first version of flexigrid used only XML.
You're welcome! Thanks for the points!