1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    sudhavani is on a distinguished road

      0  

    Default Unanswered: TypeError: d is undefined, on line record.set('rpmEmployeeID',responseObj.rpm_Employe

    Unanswered: TypeError: d is undefined, on line record.set('rpmEmployeeID',responseObj.rpm_Employe


    Code:
    Ext.onReady(function(){ 
           
           /*****************************************************
           * Save 
            * TODO -- Need to replace static vales of employeeMapping
           *****************************************************/
           Ext.widget("button",{
                  renderTo: 'empSaveAndCancel',
                  text: 'Save',
                  cls: 'srchBtn',
                  handler: function(){
                         console.log('save');
                         var storeID = Ext.get("storeNum").getValue();
                         var modifiedRecords =  rpmEmployeeMappingStore.getUpdatedRecords();
                         var changed = Ext.getCmp('employeeGridPanelId').getStore().getUpdatedRecords();
                         console.log('Sudha  '+modifiedRecords+changed);
                          if(modifiedRecords.length <= 0) {
                         //     return;
                          }
                         var mySelections = new Array();
                           Ext.getCmp('employeeGridPanelId').getStore().each(
                                function(record) {
                                    if(record.get('rpmEmployeeID') != null && record.get('rpmEmployeeID') != "") {
                                        employeeId = record.get('employeeID');
                                        rpmEmpId = record.get('rpmEmployeeID');
                                        var myObj = {
                                                "TAMSIIEmpID": employeeId,
                                                "RPMEmpID": rpmEmpId                                            
                                        };
                                            mySelections.push(myObj);
                                    }
                                }
                            );
                           
                            console.log(mySelections);
                            var obj = {storeNumber: storeID, mapping:mySelections};
                            var postBody = Ext.JSON.encode(obj);
                         Ext.Ajax.request({
                                 url : 'saveEmployeeMapping.json',
                                 method: 'POST',
                                 headers: { 'Content-Type': 'application/json' },
                                 ///params: {mapping: postBody},
                                 //params : { "mapping" : Ext.JSON.encode(mySelections), 
                                //             "storeNumber" : storeID
                                //           },
                               jsonData: {
                                        "mapping" :mySelections,// [{ "TAMSIIEmpID":"100" , "RPMEmpID":"001" },  { "TAMSIIEmpID":"102" , "RPMEmpID":"002" }, { "TAMSIIEmpID":"104" , "RPMEmpID":"003" }],
                                        "storeNumber" : storeID
                                                                  
                                             },
                                 success: function (response) {
                                //     Ext.getCmp('employeeGridPanelId').getStore().commitChanges();
                                     console.log(response);
                                             },
                                 failure: function (response) {
                                     console.log(response);
                                           }
                               });
                                      
                         //employeeStore.sync();
                         //window.location="mainStatus.do";
                         //TODO do something, remove href
                  }
           });
           
           
           /*****************************************************
           * Continue button
           *****************************************************/
           Ext.widget("button",{
                  renderTo: 'empContinue',
                  text: 'Finalize',
                  cls: 'srchBtn',
                  handler: function(){
                         //employeeStore.sync();
                         var id = Ext.get("storeNum").getValue();
                         console.log("id");
                         console.log(id);
                         Ext.Ajax.request({
                                 url : 'saveEmployeeMapping.json',
                                 method: 'POST',
                                 headers: { 'Content-Type': 'application/json' },                        
                                 params : { "test" : "testParam" },
                                 jsonData: {
                                        "mapping" : [{ "TAMSIIEmpID":"100" , "RPMEmpID":"001" },  { "TAMSIIEmpID":"102" , "RPMEmpID":"002" }, { "TAMSIIEmpID":"104" , "RPMEmpID":"003" }, { "TAMSIIEmpID":"105" , "RPMEmpID":"004" }, { "TAMSIIEmpID":"106" , "RPMEmpID":"005" }],
                                        "storeNumber" : id
                                                                   
                                             },
                                 success: function (response) {
                                                     console.log(response);
                                                     window.location="employeeMappingComplete.do?storeInfo="+id;
                                             },
                                 failure: function (response) {
                                                                 console.log(response);
                                           }
                               });
                         
                         
                         
                  }
           });
           
    
           
           /*****************************************************
           * Close button
           *****************************************************/
           Ext.widget("button",{
                  renderTo: 'empCancel',
                  text: 'Close',
                  cls: 'srchBtn',
                  handler: function(){
                         window.location="mainStatus.do";
                         //TODO do something, remove href
                  }
           });
           
           /********************************************************
           * Function which give value of a name value pair.
           ********************************************************/
           
           function getValue( key ) {
             key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
             var regexS = "[\\?&]"+key+"=([^&#]*)";
             var regex = new RegExp( regexS );
             var results = regex.exec( window.location.href );
             if( results == null )
               return "";
             else
               return results[1];
           }
           
           function getStoreNumber(){
                  if(getValue("storeNumber").length==0)
                         return Ext.get("storeNum").getValue();
                  else
                         return getValue("storeNumber");
           }
           
           
           
           /***********************************************
           * Grid
           ***********************************************/
           Ext.define('MappingObjects', {
               extend: 'Ext.data.Model',
               fields: ['employeeID','employeeName','startDate','terminationDate','rpmEmployeeID','rpmEmployeeName']
           });    
           Ext.define('RPMMappingObjects', {
               extend: 'Ext.data.Model',
               fields: ['employeeID', 'employeeName']
           });    
         
     
           var rpmEmployeeMappingStore = new Ext.data.JsonStore({    // Ext.create("Ext.data.Store", {    
               id: 'rpmEmployeeMappingStoreId',
               root:'rpmEmployees',
               fields: ['rpmEmployeeID', 'rpmEmployeeName'],
               mode:'local',
             //  model:'RPMMappingObjects',
               autoLoad: true,
               data: [{rpmEmployeeID:"", rpmEmployeeName:""}]
               
           });
           var EmployeeMappingStore = Ext.create("Ext.data.Store", {             
               model: 'MappingObjects',
               autoLoad: false
        });
    
    
           var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{
                  clicksToEdit: 1
           });
           var rowEditing =Ext.create('Ext.grid.plugin.RowEditing', { 
               
            clicksToEdit: 1,
            autoCancel: false
        });
           var Employeegrid = new Ext.grid.Panel({
                  plugins:[cellEditing],
                  selModel: {
                         selType: 'cellmodel'
                  } , 
                  
               id: 'employeeGridPanelId',
               store: EmployeeMappingStore,
               renderTo: 'employeeGrid',
               title: 'Employee Mapping',      
               width: 800,      
               height: 600,
               layout: 'fit',
               cls: 'grid',
               columns: [
                   { header: "TAMS II Employee",
                       width: 170,
                       sortable: true,
                       dataIndex: 'employeeID',
                       flex: 1
                      
                   },
                   { header: "Employee Name",
                       width: 160,
                       sortable: true,
                       dataIndex: 'employeeName',
                       flex: 2
                        
                   },
                   { header: "Start Date",
                       width: 170,
                       sortable: true,
                       dataIndex: 'startDate',                
                       flex: 3
                        
                   },
                   { header: "Termination Date",
                       width: 170,
                       sortable: true,
                       dataIndex: 'terminationDate',                   
                       flex: 4
                        
                   },
                   {header: 'RPM Site',
                       dataIndex: 'rpmEmployeeID',
                         width: 140,
                         renderer: function(value, meta, record){
                             if(value != null && value != undefined) {
                                var fname = record.data.rpmEmployeeID + " " + record.data.rpmEmployeeName;
                                return fname;
                             } else {
                                 return "";
                             }
                            },
                   
                         editor: {
                              xtype: 'combobox',
                              typeAhead: true,
                              triggerAction: 'all',
                              selectOnTab: true,
                              queryMode:'local',
                              displayField:'rpmEmployeeName',
                              valueField:'rpmEmployeeID',
                              store: rpmEmployeeMappingStore,
                              lazyRender: true,
                              listClass: 'x-combo-list-small'
                          }
                         
                   }
    
                   
                   
               ]
              
              
           });
           
           Ext.Ajax.request({
                  url : 'employees.json',
                  params: {
                  storeNumber: getStoreNumber() 
            },
               success: function(response, opts) {
                  responseObj = Ext.JSON.decode(response.responseText);
                  Ext.getCmp('employeeGridPanelId').getStore().loadData(responseObj.employees);
                  var pleaseSelectRecord = Ext.create('RPMMappingObjects', {
                      rpmEmployeeID : '-2',
                      rpmEmployeeName  : 'Please Select'
                    });
                  
                 //  rpmEmployeeMappingStore.on('load', setComboValues(responseObj), this, {single:true});
                  
                   rpmEmployeeMappingStore.loadData(responseObj.rpm_Employees);
                   rpmEmployeeMappingStore.insert(0, pleaseSelectRecord);
                   rpmEmployeeMappingStore.on('load', setComboValues(responseObj), this, {single:true});
              
                },
               failure: function(response, opts) {
                 
            }
           });
           
           function setComboValues(responseObj) {
               console.log('setComboValues: ' + responseObj);
               
               Ext.getCmp('employeeGridPanelId').getStore().each(
                       function(record) {
                           if(responseObj.employeesMapping != null && responseObj.employeesMapping.length > 0) {
                                  for(var i = 0; i < responseObj.employeesMapping.length; i++) {
                                      // console.log('1');
                                      if(record.get('employeeID') == responseObj.employeesMapping[i].tamsiiempID) {
                                          // console.log('Sudhacame here');
                                          for(var a = 0; a < responseObj.rpm_Employees.length; a++) {
                                              console.log('3');
                                              console.log('responseObj.rpm_Employees[a].rpmEmployeeID: ' + responseObj.rpm_Employees[a].rpmEmployeeID);
                                              console.log('responseObj.employeesMapping[i].rpmempID: ' + responseObj.employeesMapping[i].rpmempID);
                                                                                    
                                              if(responseObj.rpm_Employees[a].data.rpmEmployeeID == responseObj.employeesMapping[i].rpmempID) {
                                                  console.log('4 sudha '+record.get('rpmEmployeeID'));
                                                  console.log('4 suda '+responseObj.rpm_Employees[a].data);
                                                  console.log('4'+responseObj.rpm_Employees[a].data.rpmEmployeeID);
                                                  //record.set('rpmEmployeeID', {rpmEmployeeID: responseObj.rpm_Employees[a].rpmEmployeeID, rpmEmployeeName: responseObj.rpm_Employees[a].rpmEmployeeName}); //responseObj.rpm_Employees[a]);
                                                  record.set('rpmEmployeeID',responseObj.rpm_Employees[a].data.rpmEmployeeID);
                                                  //    record.set('rpmEmployeeName', responseObj.rpm_Employees[a].data.rpmEmployeeName);
                                                  console.log('After setting the value');
                                                  break;
                                              }
                                          }
                                          continue;
                              
                                      }
                                  }
                           }
                       }
                   );
           //  Ext.getCmp('employeeGridPanelId').getStore().commitChanges();
           }
           
      
    });
    I am getting type error d is undefined on line record.set('rpmEmployeeID',responseObj.rpm_Employees[a].data.rpmEmployeeID);.
    I can see rpmEmployeeID in side record.data.(In firebug). Any suggestion is appreciated.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,668
    Answers
    3354
    Vote Rating
    746
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Best way to debug is to set a breakpoint and follow the code till you find the error.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    sudhavani is on a distinguished road

      0  

    Default


    Code:
     replaceElement : function(el, replacement, domReplace){         var index = !isNaN(el) ? el : this.indexOf(el), 
                d; 
            if(index > -1){ 
                replacement = Ext.getDom(replacement); 
                if(domReplace){ 
                    d = this.elements[index]; 
                    d.parentNode.insertBefore(replacement, d); 
    
                    Ext.removeNode(d); 
                } 
                Ext.Array.splice(this.elements, index, 1, replacement); 
            } 
            return this; 
        },
    I am getting error on this line.
    d.parentNode.insertBefore(replacement, d);

    Thanks

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar