键键的专栏

永远的键键

用户操作
[即时聊天] [发私信] [加为好友]
李林键ID:lilinjian2001
24179次访问,排名4889好友2人,关注者4
创造生活
lilinjian2001的文章
原创 26 篇
翻译 0 篇
转载 44 篇
评论 9 篇
詠遠啲鍵鍵的公告
News
新浪快报:



今日天气



———————————
E-mail:
lilinjian2001@163.com
最近评论
zhangyue8965:能不能说说 OBJECT中的参数和他下边的参数是什么意思吗??
zhangyue8965:能不能说说 OBJECT中的参数和他下边的参数是什么意思吗??
陈晓纪:谢谢你的代码!困扰我很长时间了,终于解决了!但是你的代码也有问题,第42页有10条记录,而你的程序判断start+limit-1(420+20-1)为439,显然是不对的,因为最后一页只有10条记录,所有程序应该进行判断。正确代码应该是这样:
int start = int.Parse( Request.Params["start"] ); //获取页面显示的起始数
……
mldstk:wow power leveling
mldstk:wow power leveling
文章分类
收藏
    相册
    Temp
    暗黑
    E书下载
    西安信息咨询网
    友情链接
    Ajax中国
    Extjs官方網站
    Leo——成长但还没变老
    zjcxc(邹建)的Blog - SQL Server
    卡修
    孟子E章
    李洪根的blog-专注软件开发技术
    白鸦,以用户为中心的设计(RSS)
    源码下载
    中国盟动力源码站
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 学习EXT第四天--开始使用Grid收藏

    新一篇: 学习EXT第五日--Grid组件的简易分页 | 旧一篇: 学习EXT第三天:Menu组件

    本教程将以XML为数据源,带你进入Grid的世界。

    本文涉及的范例代码,可以在这里下载。一个完成好的例子可在这里找到。

    步骤一 定义数据(Data Definition)

    首先要让Grid知道XML文档定义了每一行是什么数据。正如所见,我们命名了"item"在下面的XML样本中。

    XML样本数据 文件名:sheldon.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2006-06-28">
        
    <OperationRequest>
            
    <HTTPHeaders>
                
    <Header Name="UserAgent"
                        Value
    ="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser; Avant Browser; .NET CLR 1.0.3705; .NET CLR 2.0.50727; .NET CLR 1.1.4322; Media Center PC 4.0; InfoPath.2)"></Header>
            
    </HTTPHeaders>
            
    <RequestId>18CZWZFXKSV8F601AGMF</RequestId>
            
    <Arguments>
                
    <Argument Name="Service" Value="AWSECommerceService"></Argument>
                
    <Argument Name="AssociateTag" Value="ws"></Argument>
                
    <Argument Name="SearchIndex" Value="Books"></Argument>
                
    <Argument Name="Author" Value="Sidney Sheldon"></Argument>
                
    <Argument Name="SubscriptionId" Value="1A7XKHR5BYD0WPJVQEG2"></Argument>
                
    <Argument Name="Version" Value="2006-06-28"></Argument>
                
    <Argument Name="Operation" Value="ItemSearch"></Argument>
            
    </Arguments>
            
    <RequestProcessingTime>1.05041599273682</RequestProcessingTime>
        
    </OperationRequest>
        
    <Items>
            
    <Request>
                
    <IsValid>True</IsValid>
                
    <ItemSearchRequest>
                    
    <Author>Sidney Sheldon</Author>
                    
    <SearchIndex>Books</SearchIndex>
                
    </ItemSearchRequest>
            
    </Request>
            
    <TotalResults>203</TotalResults>
            
    <TotalPages>21</TotalPages>
            
    <Item>
                
    <ASIN>0446355453</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446355453%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446355453%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>Master of the Game</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446613657</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446613657%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446613657%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>Are You Afraid of the Dark?</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446357421</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446357421%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446357421%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>If Tomorrow Comes</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446607207</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446607207%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446607207%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Vision</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>Tell Me Your Dreams</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446357448</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446357448%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446357448%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>Bloodline</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446532673</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446532673%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446532673%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>The Other Side of Me</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446356573</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446356573%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446356573%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>A Stranger in the Mirror</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0060198346</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0060198346%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0060198346%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>William Morrow &amp; Company</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>The Sky Is Falling</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446354732</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446354732%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446354732%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>Nothing Lasts Forever</Title>
                
    </ItemAttributes>
            
    </Item>
            
    <Item>
                
    <ASIN>0446341916</ASIN>
                
    <DetailPageURL>
                    http://www.amazon.com/gp/redirect.html%3FASIN=0446341916%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446341916%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
                
    </DetailPageURL>
                
    <ItemAttributes>
                    
    <Author>Sidney Sheldon</Author>
                    
    <Manufacturer>Warner Books</Manufacturer>
                    
    <ProductGroup>Book</ProductGroup>
                    
    <Title>The Naked Face</Title>
                
    </ItemAttributes>
            
    </Item>
        
    </Items>
    </ItemSearchResponse>

     

    接着需要定义某一列为“统一标识(Unique Identifier)”,即ID,根据“id"所设置的那个节点来读取值(样本代码第九行)。本例中的样本数据是”ASIN"列。

    数据定义的最后部分就是指定你需要显示的字段(Fields),把这些字段放到一个数组之中,并保证这些字段与你的XML数据中元素名称是一致的,而且还要注意先后顺序,这里的顺序不需要和XML文件中顺序一致。

    var dataStore = new Ext.data.Store({
                proxy : 
    new Ext.data.HttpProxy({url: 'XML/sheldon.xml'}),
                reader : 
    new Ext.data.XmlReader(
                    {record : 
    'Item',id : 'ASIN'},
                    [
    'Author','Manufacturer','ProductGroup','Title']
                )
            });

    步骤二 列模型(Column Model)

    下一步便是定义Column Model 列模型。简单地说,就是通过一些属性的设置,决定每一列怎么控制或怎么显示,这是一个由每列的配置参数组成的数组。注意,出现的顺序应该与刚才定义“字段”的数组一致。较常见的参数通常是header和width,所以你会觉得这两项是必须要设置的,然而宽度(width)其实不总是需要的,因为稍后我们将使用autoWidth/Height来代替。

    列模型样本

    var colModel = new Ext.grid.ColumnModel([
            {header : 
    "Author",width:120,dataIndex:'Author'},
            {header : 
    "Manufacturer",width:180,dataIndex:'Manufacturer'},
            {header : 
    "ProductGroup",width:115,dataIndex:'ProductGroup'},
            {header : 
    "Title",width:100,dataIndex:'Title'}
            ]);

    最后是将DataStore和Column Model两样东西传入到Grid,渲染结果,然后加载来自DataStore的数据,这些就是你让Grid工作起来的所有因素!

    进行渲染!

     

    var grid = new Ext.grid.GridPanel({
                el : 
    'GridXml',
                ds : dataStore,
                cm : colModel,
                height:
    350,
                width:
    600
            });
            
            grid.render();
            dataStore.load();

    在body部分加入:

    <div id="GridXml"></div>

    发表于 @ 2008年01月14日 11:39:00|评论(loading...)|编辑

    新一篇: 学习EXT第五日--Grid组件的简易分页 | 旧一篇: 学习EXT第三天:Menu组件

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © 詠遠啲鍵鍵