我不能在ext js分组网格中加载数据。对于ExtJS的分机js分组网格不能加载json数据
我有以下代码grouping.js
Ext.onReady(函数(){
Ext.QuickTips.init();
var xg = Ext.grid;
var documentType= "";
var fileName="";
var size="";
var fileGPath="";
// shared reader
var reader = new Ext.data.ArrayReader({}, [
{name: 'filename'},
{name: 'size'},
{name: 'author'},
{name: 'date', type: 'date', dateFormat: 'Y-m-d H:i:s'},
{name: 'action'},
{name: 'document'}
]);
变种商店=新Ext.data.GroupingStore({ 读者:阅读器, URL :'DocumentListService.jsp', root:'Documents', sortInfo:{field:'filename',direction:“ASC”}, fields:[ {name:'filename',mapping:'FileName'}, {name:'size',mapping :'Size'}, {name:'author',mapping:'Author'}, {name:'date',mapping:'Date'}, {name:'action',mapping:''}, {name:'document',mapping:'Document'} ], groupField:'document' });
var grid = new xg.GridPanel({
id : 'myGridId',
store: store,
columns: [
{id:'filename',header: "File Name", width: 60, sortable: true, dataIndex: 'filename'},
{header: "Size", width: 20, sortable: true, dataIndex: 'size'},
{header: "Author", width: 20, sortable: true, dataIndex: 'author'},
{header: "Date", width: 20, sortable: true, dataIndex: 'date'},
{header: "Action", width: 20, sortable: true, dataIndex: 'action'},
{header: "Document", width: 20, sortable: true, dataIndex: 'document',hidden:'true'}
],
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs[0].get("filename")=="" ? "0" : values.rs.length]} {[values.rs.length > 1 ? "Documents" : "Document"]}) <a href="#" onClick="javascript:document.getElementById(\'hdnId\').value=\'{text}\';document.getElementById(\'form-file-file\').click();" style="align:right"><img src="images/image_add.png" alt="Upload Document" style="border:none;margin-left:390px;"/></a>'
}),
frame:true,
width: 700,
height: 450,
collapsible: true,
animCollapse: false,
title: 'Document Library',
iconCls: 'icon-grid',
renderTo: 'docUpload'
});
var fp = new Ext.FormPanel({
renderTo: 'fi-form',
fileUpload: true,
width: 500,
frame: true,
title: 'File Upload Form',
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Select a File to import',
fieldLabel: 'File',
name: 'file',
buttonCfg: {
text: '',
iconCls: 'upload-icon'
},
listeners: {'fileselected': function(v){
if(fp.getForm().isValid()){
fp.getForm().submit({
url: 'FileUpload.jsp',
waitMsg: 'Uploading your file...',
success: function(fp, jsonObj){
fileName = jsonObj.result.fileName;
size = jsonObj.result.size;
fileGPath = jsonObj.result.fileGPath;
documentType = (document.getElementById("hdnId").value).replace("Document: ","");
addDataToGrid(fileName,fileGPath,size,documentType);
Ext.getCmp('myGridId').getStore().loadData(xg.dummyData);
msg('Success', 'Successfully uploded on the server');
},
failure : function(fp, o){
msg('Failure', 'Failed to upload');
}
});
}
}
}
}]
});
});
,我已经按照如在DocumentListService.jsp JSON字符串
{ “DocumentList”:[{ “DocumentGroup”: “发票”, “isDocumentBundle”:真, “isWritable”:真, “文档”: [{ “文件名”: “ABC.doc”, “大小”: “123”, “作者”: “XYZ”, “日期”:“\ /日期(1238025600000) \“, ”FileGPath“:”xyz doc“, ”Document“:”发票 “ },{ ”文件名“: ”ABC.doc“, ”大小“: ”123“, ”作者“: ”XYZ“, ”日期“:” \ /日期(1238025600000)\/”, “FileGPath”: “ABC DOC”, “文档”: “发票” }] }, { “DocumentGroup”: “SOP”, “isDocumentBundle”:真, “isWritable”:真, “Documents”: [{“FileName”:“ABC.doc”, “Size”:“123”, “Author”:“xyz”, “日期”: “\ /日期(1238025600000)\ /”, “FileGPath”: “XYZ DOC”, “文档”: “SOP” }] } ] }
仍然我不能能加载数据,
plz帮助我,并解决我的问题,我到底犯了什么错误。
但如果我将设置根:'DocumentList'那么我也无法找到网格中的数据,是否有任何映射问题?感谢您的回复 – Sanju
实际上是的,它仍然是一个问题,因为您有多个“文档”数组,您试图保存到商店中。我会编辑我的答案。 – nscrob