返回从ASP.net的数据一个ExtJS网格 [英] Returning data from ASP.net to an ExtJS Grid

查看:108
本文介绍了返回从ASP.net的数据一个ExtJS网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑写在HTML和JavaScript(通过ExtJS的)一个网格,我现在需要一个ASP.net Web应用程序中实现的原型/样机。没有任何人有任何指针就如何将数据传递到网格(到GroupingStore,特别是)。

I've been given a prototype/mockup of a grid written in html and javascript (via ExtJS) that I now need to implement within an ASP.net web application. Does anyone have any pointers as to how to pass data to the grid (to a GroupingStore, specifically).

我宁愿没有返回的XML / JSON Web服务或帮助页面的扩散,所以如果有使用客户端回调或页面方法的方式(你就不能告诉我不是特别熟悉或者 - 时髦宾果!)或诸如此类,这将是preferred。

I'd rather not have a proliferation of web services or helper pages returning XML/JSON so if there's a way to use Client callbacks or Page Methods (Can't you tell I'm not particularly familiar with either - buzzword bingo!) or somesuch, that would be preferred.

请,不建议我使用jQuery,内置的ASP.net网格或任何其他UI框架。使用ExtJS的电网已经由权力,是硬性规定,所以这是我使用的网格,是好还是坏:)

Please, no recommendations that I use jQuery, the built-in ASP.net grid, or any other UI framework. The use of the ExtJS grid has been mandated by the powers that be, so that's the grid I'm using, for better or worse :)

推荐答案

下面是一个低技术的解决方案。它不需要使用Web服务或任何其他额外的技术。

Here's a low tech solution. It doesn't require use of web services or any other additional technologies.

第1步

有一个ASPX页面,它有一个放慢参数,调用和像这样的:

Have an ASPX page that takes one paramter, and invoked like this:

http://mysite.com/query.aspx?sql=select * from orders where status = 'open'

第2步

在code的背后,做这样的事情。

In the code behind, do something like this

void Page_Load(object sender, EventArgs e)
{
   Response.ContentType="text/json"; 
   DataTable contents = ExecuteDataTable(Request["sql"]);
   Response.Write( JRockSerialize( contents ) );
   Response.End();
}

您可以使用 JRock 序列化的数据表,以JSON。
恕我直言,这给了最干净的JSON。

You can use JRock for serializing a data table to JSON. IMHO this gives the cleanest JSON.

这就是让数据表来排序的JSON ...

So that's getting DataTable to JSON sorted...

警告:这显然是一个简单的例子。你不应该传递查询字符串SQL,因为它是不安全的(你可以使用命名的查询和参数来代替)。

第3步

在您的ExtJS code,创建使用JSON数据存储网格如本的 ext的例子的。将数据存储网​​址:来与相应的查询字符串参数的query.aspx页面。

In your ExtJS code, create a grid with Json datastore as shown in this Ext example. Set the data store url: to that of your query.aspx page with appropriate query string parameters.

您还需要设置了列网格,在ExtJS的例子再次出现。

You'll also need to set the columns up for the grid, again shown in the ExtJs example.

另外...

我是真的IM pressed当我看着 Coolite样品最近。他们是一个ExtJS的合作伙伴,并提供良好的ASP.NET和放大器; ExtJS的经验。不,我不为他们工作:)我还没试过他们的网格,但它可能是无痛的(有代价)。

I was really impressed when I looked at the Coolite samples recently. They are an ExtJS partner and provide a good ASP.NET & ExtJS experience. And no, I don't work for them :) I haven't tried their grid, but it might be painless (at a price).

这篇关于返回从ASP.net的数据一个ExtJS网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆