0
- 我有一個帶有按鈕的jsp頁面。
- 點擊該按鈕,它會動態地創建一個dojo網格。
- 網格被加載後,我通過網格迭代,如果有特定的值,整個行被選中。
- 我通過使用下面的代碼實現了它,行被選中,但出現錯誤。
- 錯誤: 「錯誤:dojo.data.ItemFileReadStore:無效項的參數」
- 正在使用dojoX.grid.DataGrid(1.7)
下面是創建動態網格的代碼:在網格加載後對焦或選擇該行
var ioArgs = {
url: "./DynamicDBServlet",
content: { TABLE_NAME:tableName,WHERE_CONDN:condtn,COLUMNS:gridColumnName,ACTION:'select'},
handleAs: "json",
load: function(response) {
//alert(response["items"][0].USER_ID);
var tbl = document.getElementById(gridID);
//alert(tbl);
if(tbl) tbl.parentNode.removeChild(tbl);
var gridLayout = [];
var key;
colmn=gridColumnName.split(',');
var i=0;
while(i<colmn.length) {
if(colmn[i]=="STATUS"){
key = colmn[i];
gridLayout.push({
field: key,
name: displayName[i],
formatter:function(opvalue){
//alert(opvalue);
opvalue = parseInt(opvalue);
if(opvalue==1){
return "Executing";}
if(opvalue==2){
return "Suspended";}
if(opvalue==3){
return "Completed";}
if(opvalue==4){
return "Aborted";}
if(opvalue==5){
return "Error";}
if(opvalue==6){
return "Terminated";}},
width: '200px',
editable: false});
i++;
}if(colmn[i]=="PRIORITY"){
key = colmn[i];
gridLayout.push({
field: key,
name: displayName[i],
formatter:function(opvalue){
if(opvalue==1){
return "High";}
if(opvalue==8){
return "Normal";}
if(opvalue==15){
return "Low";}
},
width: '200px',
editable: false});
i++;
}if(colmn[i]=="PROCESS_METADATYPE"){
key = colmn[i];
gridLayout.push({
field: key,
name: displayName[i],
formatter:function(opvalue){
if(opvalue==4497){
return "Provisioning Sub Process";}
if(opvalue==4496){
return "Provisioning Loop";}
if(opvalue==4494){
return "Main Process";}
},
width: '200px',
editable: false});
i++;
}if(colmn[i]=="ORDER_TYPE"){
key = colmn[i];
gridLayout.push({
field: key,
name: displayName[i],
formatter:function(opvalue){
if(opvalue==4488){
return "Training Order";}
},
width: '200px',
editable: false});
i++;
}else{
key = colmn[i];
gridLayout.push({
field: key,
name: displayName[i],
width: '200px',
editable: false});
i++;
}
}
//alert(gridLayout);
var gridStore = new dojo.data.ItemFileWriteStore({
data: response
});
var dumm = dijit.byId('dynamicgrid'+tableName);
if(dumm) {
dumm.destroy();
}
var finderResponse = new dojox.grid.DataGrid({
id:"dynamicgrid"+tableName,
query: { },
store:gridStore,
structure: gridLayout,
selectionMode: "single"
}, document.createElement("div"));
dojo.byId(parentDiv).appendChild(finderResponse.domNode);
//var varb=dijit.byId("finderResponseGrid"+tableName);
//alert(varb);
//varb.layout.setColumnVisibility(0, false);
gbshowgridFlag = true;
finderResponse.startup();
//dijit.byId('dynamicgridCWPROCESS').focus.setFocusIndex(0);
try{
for(var i=0; i < dijit.byId('dynamicgridCWPROCESS').rowCount; i++){
var items = dijit.byId('dynamicgridCWPROCESS').getItem(i);
var value=dijit.byId('dynamicgridCWPROCESS').store.getValue(items,"PROCESS_ID");
if(value=="2507"){
dijit.byId('dynamicgridCWPROCESS').selection.setSelected(i,true);
}
}
if(defineDbl){
getProcessgrid();
}
}catch(e){
alert(e);
}
},
error: function(error) {
alert("An unexpected error occurred: " + error);
}
};
var deferred = dojo.xhrPost(ioArgs);
請提供一個jsfiddle示例,它會產生相同的錯誤... – 2013-02-15 11:32:23
對不起。這將是困難的。我有'n'個代碼。 – Rachel 2013-02-15 11:37:39
這樣很難找到問題 – 2013-02-15 11:39:46