在我的项目中使用Dojo Gridx。这些是我的列名 id,field1,field2,活动状态
我有一个作业,当点击列活动状态需要更改活动状态值,列图标和field1,field2值时。
例如:如果有效状态值是' Y'当我点击,然后我想更改field1,field2的值并更改活动状态图标。我可以借助下面提到的代码实现这个功能。
但问题是,field1是可编辑的,如果我单击活动状态列而不编辑field1,下面提到的代码工作正常。我编辑后,如果我点击下面提到的活动状态栏代码不起作用。但是服务器端的值发生了变化,DB端工作正常。我不知道有什么问题让一些人让我理解。我附上了我的代码供您参考。
require([" dojo / request"," dojo / i18n!RW / nls / appResources"],function(request,bundle){ request.get(" / RW / rest /" + that.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);
}
},
];
答案 0 :(得分:1)
你必须使用&#39; getCellWidgetConnects&#39;用于将事件绑定到单元小部件。还要确保在编辑后保存网格模型。