Dojo   发布时间:2022-04-21  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了dojo显示列表 Grid Cell Store大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

框架是ssi这个省略

今天先写Grid,其实就是列表。大致步骤就是

post请求,发送参数,返回data,new 一个cell,显示列表。

发送参数,和返回参数详细下一节再写。

1 结构

require([

"dojox/grid/DataGrid",
"dojo/store/Memory",
"dojo/data/ObjectStore",
"dojo/request",
"dojox/grid/_checkBoxSELEctor",
"dojo/_base/lang",
"dojo/_base/array",
"dojox/grid/cells",
"dojo/domReady!"
],function( DataGrid,Memory,ObjectStore,request,_checkBoxSELEctor,lang,baseArray,gridCells){

// code

request.post................

});

注意:require和function里面是一一对应的,fun里面名字可以改,但是顺序不能颠倒,跟java一个道理。

2 请求

request.post("institutionList.action",

{

data:{变量名:数据},// 传递查询参数 ,这里可以不要。下一节重点讲

handleAd: "json" // json格式传递

}

).then(function(data){

var datas = eval(data.result); //result是action里面的一个变量,见下面的action方法

var tempStore = new Memory({data:datas});//转换成Memory

var dataStore = new ObjectStore({object:tempStorE});//转换成Store

var cells = [

{ name: "组名称",field: "institutionId",width:"350px",styles:"text-align:center;"},
{ name: "组描述",field: "institutionName",
{ name: "操作",field:"parId",width:"192px",styles:"text-align:center;"}

]

var gridLayout = [

// 这里可以添加checkBox
cells
];

grid = new DataGrid({
store: dataStore,//action请求获得的store
query: { institutionId: "*" },//精确查询,可以不要
autoHeight: true,
structure: gridLayout // 定义行
},"grid"); //显示位置

});


3 jsp只要这样就行,头部引入自己写

<body>
<div id="grid"></div>
</body>


4 补充 action方法

/**
* 查询机构列表
*
* @return
* @throws Exception
*/
public String queryInstitutionList() throws Exception {

institutionInfoList = institutionservice.queryInstitution(); //service自己写

result = JSONUtil.serialize(institutionInfoList); //要有get set方法

log.debug(result);

return succesS;

}

注意:查询出来的数据列表字段名要跟cell里面的对应,要不不显示SELEct institutionid as institutionId

大佬总结

以上是大佬教程为你收集整理的dojo显示列表 Grid Cell Store全部内容,希望文章能够帮你解决dojo显示列表 Grid Cell Store所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。