网格加载后聚焦或选择行 我有一个带有按钮的jsp页面 单击按钮后,它将动态创建dojo网格 加载网格后,我将遍历网格,如果有特定值,则选择整行 我通过使用下面的代码实现了它,行被选中,但是我得到了一个错误 错误:“错误:dojo.data.ItemFileReadStore:无效的项参数” Am使用dojoX.grid.DataGrid(1.7)
以下是创建动态栅格的代码:网格加载后聚焦或选择行 我有一个带有按钮的jsp页面 单击按钮后,它将动态创建dojo网格 加载网格后,我将遍历网格,如果有特定值,则选择整行 我通过使用下面的代码实现了它,行被选中,但是我得到了一个错误 错误:“错误:dojo.data.ItemFileReadStore:无效的项参数” Am使用dojoX.grid.DataGrid(1.7),grid,selection,dojo,dojox.grid.datagrid,Grid,Selection,Dojo,Dojox.grid.datagrid,以下是创建动态栅格的代码: var ioArgs = { url: "./DynamicDBServlet", content: { TABLE_NAME:tableName,WHERE_CONDN:condtn,COLUMNS:gridColumnName,ACTION:'select'}, handleAs: "json", load: function(response) {
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);
var ioArgs={
url:“./DynamicDBServlet”,
内容:{TABLE_NAME:tableName,其中_CONDN:condtn,COLUMNS:gridColumnName,ACTION:'select'},
handleAs:“json”,
负载:功能(响应){
//警报(响应[“项”][0]。用户ID);
var tbl=document.getElementById(gridID);
//警报(tbl);
if(tbl)tbl.parentNode.removeChild(tbl);
var gridLayout=[];
var键;
colmn=gridColumnName.split(',');
var i=0;
while(i此代码帮助我选择网格中的行:
grid.selection.select(rowIndex);
就你而言:
finderResponse.selection.select(rowIndex);
我希望这能解决您的问题。请提供一个产生相同错误的JSFIDLE示例…很抱歉。这将很困难。我有n个代码。这样很难找到问题
function selectRowByYourOwn(){
var row = null;
// you have to get is some have.. try onSelected='yourOwnFn', on your table tag or your div tag.
// function yourOwnFn(rowID){ row = rowID;}
grid.selection.clear();
grid.selection.setSelected(row, true);
grid.render();
}