paging - SmartGWT 分页如何工作?

标签 paging smartgwt

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

我看到它在 showcase 中工作,但我在任何地方都找不到它的记录。 (javadoc 中的信息远远不足以理解正在发生的事情。)

我有一个 ListGrid 和一个与我的服务器交互的自定义​​数据源。

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

我必须做什么:

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

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

最佳答案

如果您使用的是 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 服务器端代码负责将数据绑定(bind)与数据库表连接。 2) 如果您需要对服务器数据绑定(bind)进行模式控制,您可以在滚动(获取)或插入/更新/删除时调用您自己的服务器 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;  
}

关于paging - SmartGWT 分页如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2876804/

相关文章:

gwt - SmartGwt DateItem useTextField=true - 如何使文本输入字段不可编辑

javascript - SmartGWT 与 React.js : a good widget library for the latter?

c# - 客户端从 cosmos db 中存储的延续 token 在哪里以及如何维护

NHibernate:返回具有分页子集合的对象的最简单方法?

css - 如何为不同状态的 TreeNode 应用不同的样式?

gwt - 在 Smart GWT 中获取选定的 SectionStack 部分

java - SmartGwt - 显示标签的全部内容

operating-system - 使用线性页表进行分页虚拟地址转换

paging - 假设一台机器有48位的虚拟地址和32位的物理地址

algorithm - WSclock 页面替换算法和时钟节拍