【问题标题】:How does SmartGWT paging work?SmartGWT 寻呼是如何工作的?
【发布时间】:2010-05-20 18:42:04
【问题描述】:

有人可以向我解释一下 SmartGWT 中的分页是如何工作的吗?

我看到它在 showcase 中工作,但我无法在任何地方找到它的文档。 (javadocs 中的信息远远不足以理解发生了什么。)

我有一个 ListGrid,以及一个与我的服务器交互的自定义​​ DataSource。

假设我想在 ListGrid 中设置 25 条记录的页面大小。

我该怎么办:

  • 在 ListGrid 中?
  • 在我的自定义数据源中(可以访问 DSRequest 和 DSResponse 对象)?
  • 在我的服务器上?

SmartGWT 客户端发送给服务器的参数是什么,SmartGWT 客户端期望返回的参数是什么?

【问题讨论】:

    标签: paging smartgwt


    【解决方案1】:

    如果您使用 Smart GWT LGPL:

    请阅读 RestDataSource 的 Javadocs,因为它详细解释了这一点:http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RestDataSource.html

    还可以查看 RestDataSource 示例:http://www.smartclient.com/smartgwt/showcase/#featured_restfulds

    如果您使用的是 Smart GWT EE,那么 1) 如果您使用的是 SQL 连接器,那么您在服务器上编写的代码为 0,因为 Smart GWT 服务器端代码负责将数据绑定与您的数据库表连接起来。 2) 如果您需要对服务器数据绑定进行模式控制,您可以在滚动(获取)或插入/更新/删除发生时调用自己的服务器 API。看看这个样本的来源:http://www.smartclient.com/smartgwtee/showcase/#javabeans

    单击“查看源代码”按钮并检查 SupplyItemDMI 类的源代码。注意如何获取请求的起始行、结束行参数。

    // By default, for a DSRequest of type "fetch", a method named "fetch" is invoked.  
    // You can customize this via the <serverObject> declaration.  
    public DSResponse fetch(DSRequest dsRequest)  
        throws Exception {  
       log.info("procesing DMI fetch operation");  
    
        // Fetch a List of matching SupplyItem Beans from some pre-existing Java object model  
        // provided by you, represented by "SupplyItemStore" in this example  
        List matchingItems =  
            SupplyItemStore.findMatchingItems((Long) dsRequest.getFieldValue("itemID"),  
                    (String) dsRequest.getFieldValue("itemName"));  
    
        // this implementation shows data paging (returning only ranges of requested records)  
        long startRow = dsRequest.getStartRow();  
        long endRow = dsRequest.getEndRow();  
    
        long totalRows = matchingItems.size();  
        DSResponse dsResponse = new DSResponse();  
        dsResponse.setTotalRows(totalRows);  
        dsResponse.setStartRow(startRow);  
    
        endRow = Math.min(endRow, totalRows);  
        dsResponse.setEndRow(endRow);  
    
        // trim the data to the requested range of records.  In a real application, the startRow  
        // and endRow would be passed to the ORM layer or to SQL for maximum efficiency.  
        List results;  
        if (totalRows > 0) {  
            results = matchingItems.subList((int) dsResponse.getStartRow(),  
                    (int) dsResponse.getEndRow());  
        } else {  
            results = matchingItems;  
        }  
    
        // just return the List of matching beans  
        dsResponse.setData(results);  
    
        return dsResponse;  
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-10
      • 1970-01-01
      • 1970-01-01
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2011-03-31
      相关资源
      最近更新 更多