Column values not changed after edit the coulmn in GRIDX

498 Views Asked by At

Am using Dojo Gridx in my project. These are my columns names id, field1, field2, active status

I have a assignment, when click column active status need to change the active status value, column icon and field1, field2 values.

For example : if active status values is 'Y' when I click, then I want to change the value of field1, field2 and change active status icon. I can achieve this functionality with the help of below mentioned code.

But here the problem is, field1 is editable, if I click active status column with out edit the field1 the below mentioned code working fine. After I edited, if I click active status column below mentioned code is not working. But values changes in server side, DB side working fine. I don't know what problem please some one make me to understand. I have attached my code for your reference.

require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){ request.get("/RW/rest/"+that.resourcePath,{handleAs : 'J'}).then( function(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);
                            }
                        },
                    ];  
1

There are 1 best solutions below

0
On BEST ANSWER

You have to use 'getCellWidgetConnects' for binding events to cell widgets. Also make sure you have your grid model saved after editing.