我在我的项目中使用Dojo Gridx。这些是我的列名Id, field1, field2,激活状态
我有一个作业,当点击列活动状态需要改变活动状态值,列图标和field1, field2值。
例如:如果我点击时激活状态值是'Y',那么我想改变field1, field2的值,改变激活状态图标。我可以在下面提到的代码的帮助下实现这个功能。
但这里的问题是,field1是可编辑的,如果我单击活动状态列与编辑field1下面提到的代码工作良好。我编辑后,如果我点击活动状态列下面提到的代码不工作。但是值在服务器端变化,DB端工作良好。我不知道什么问题,请有人让我明白。我附上了我的代码供你参考。
要求(["dojo/请求"、"dojo/i18n !RW/nls/appResources")、功能(请求,包){request.get("/RW/休息/"+。resourcePath,{handleAs: 'J'}).then(函数(J) {
that.JGloData=J;
var dataToPopulate = {
identifier: 'id',
items: that.JGloData
};
review.app.defectClassAE.partStore = new dojo.data.ItemFileWriteStore({
data : dataToPopulate
});
review.app.defectClassAE.partStructure = [
{
field : 'id',
name : that.J.defect_id,
width : '5%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field1',
name : that.J.defect_class,
width : '25%',
dataType : 'string',
alwaysEditing : false,
editable : true,
editor : dijit.form.Textarea,
},
{
field : 'field2',
name : that.J.defect_activate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field3',
name : that.J.defect_deactivate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{ field: 'activeStatus', name: bundle.RT_QLIST_ACTIVATE, filterable: false, width: '20%' ,editable : false,
widgetsInCell: true,
decorator: function(){
return "<button data-dojo-type='dijit/form/Button' data-dojo-attach-point='btnactivate' data-dojo-props='showLabel: false' type='button'>Activate</button>";
//return "<div data-dojo-type='dijit.form.Button' data-dojo-attach-point='btnactivate'></div>";
},
setCellValue: function(gridData, storeData, cellWidget){
if(gridData == "Y"){
cellWidget.btnactivate.set('iconClass', "rtIcondeactivateReviewType");
}else{
cellWidget.btnactivate.set('iconClass', "rtIconactivateReviewType");
}
(function(cellWidget){
dojo.connect(cellWidget.btnactivate,"onClick",function(){
//var that = this;
var rawData = cellWidget.cell.row.rawData();
var cell = cellWidget.cell;
var DI="";
var activeStatus="";
DI=rawData.DI;
activeStatus=rawData.activeStatus;
if(DI!=null && DI!=""){
require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){
request.get("/RW/rest/"+that.resourcePath+"/defectActOrDea/"+DI,{handleAs : 'J'}).then(
function(J){
if(activeStatus=='Y' || activeStatus==""){
var deactvalues = {
'activeStatus' : 'N',
'field3':that.getTodayDate(),
'field2':""
};
cell.row.setRawData(deactvalues);
that.set('iconClass', "rtIcondeactivateReviewType");
}
else{
var actvalues = {
'activeStatus' : 'Y',
'field2':that.getTodayDate(),
'field3':""
};
cell.row.setRawData(actvalues);
that.set('iconClass', "rtIconactivateReviewType")
}
},
function(error){
showErrorNotification(that.J.defect_act_deact_error);
}
);
});
}
});
})(cellWidget);
}
},
];
必须使用'getCellWidgetConnects'来将事件绑定到单元格小部件。还要确保在编辑后保存网格模型。