【问题标题】:Dojo grid: load data from html markupDojo 网格:从 html 标记加载数据
【发布时间】:2015-03-17 07:18:53
【问题描述】:

我目前正在使用dojox.grid.DataGrid 显示数据,其中向服务器发送第二个请求以获取数据。我正在使用spring MVC,因此我可以使用视图中的模型数据(准确地说是使用JSTL)填充数据(来自标记)。而且我无法实现这一目标,因为我找不到通过 html 标记获取网格内数据的方法。道场网格是否支持仅通过脚本(存储)填充数据?

我找到了可以使用的dojox.data.HtmlStore。但只是确保没有更好的解决方案。

【问题讨论】:

    标签: spring-mvc dojo jstl dojox.grid.datagrid


    【解决方案1】:

    是的,dojox.grid.DataGrid 可以使用 HTML 标记来定义。

    示例代码:

    <table data-dojo-type="dojox.grid.DataGrid" >
      <thead>
        <tr>
          <th field="fieldName" >Col1</th>
          <th field="fieldName" >Col2</th>
        </tr>
      </thead>
    </table>
    

    所以在您的jsp 中有生成上述结构的逻辑。

    更多信息可以找到here

    对于数据部分,您可以这样做:

     <table data-dojo-type="dojox.grid.DataGrid" >
          <thead>
            <tr>
              <th field="fieldName" get="myData.getCol1">Col1</th>
              <th field="fieldName" get="myData.getCol2">Col2</th>
            </tr>
          </thead>
        </table>
    

    Javascript 函数:

    myData.getCol1 = function(colIndex,item){
      return "<place the actual content from your jstl variables here>";
    };
    
    While 
    

    上述解决方案不是更聪明的方式,请使用 store 并从服务器返回构造的 json 对象。

    【讨论】:

    • 这只是定义了网格。能不能填一样的数据?就是这个问题。
    • 谢谢你,但它不适合我。如果您可以让我知道文档(例如),将会非常友好。文档和支持是 dojo 框架中最糟糕的部分。
    【解决方案2】:

    dojox.data.HtmlStore 可以使用。这不是一个简单的解决方案,但却是最简单的解决方案。

    可以在此处找到带有示例的文档:http://dojotoolkit.org/reference-guide/1.10/dojox/data/HtmlStore.html

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 2012-02-14
      • 2012-06-26
      • 1970-01-01
      • 2011-09-25
      • 2013-06-10
      • 1970-01-01
      • 2010-12-03
      • 1970-01-01
      相关资源
      最近更新 更多