Author Topic: Get value of different cell, while in other selected cell  (Read 5785 times)

gammax500

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 16
    • View Profile
Get value of different cell, while in other selected cell
« on: September 24, 2015, 08:12:31 pm »
I have a grid with a cell containing a primary key value that I want to get while in a different cell that's in the same row.
I've tried various methods but not having much luck. Let me know if I need to provide more details.

////  code outline >
A clip from the dataModel:
   
     dataModel: {
                dataType: "JSON",
                location: "remote",
                recIndx: "admin_login_id", //primary key
                method: "GET", ...

And a clip of the column model and the function within the column "password".  I want to get the value of "admin_login_id" to pass to a component doing record validation:

      colModel: [
                { title: "ID", width: 50, dataType: "integer", editable: false , hidden: false , dataIndex: "admin_login_id"  },
      { title: "First Name", width: 100, dataType: "string", dataIndex: "fname",  ....
....
....
....
                { title: "Password", width: 150, dataType: "string", dataIndex : "password",
                validations: [

                   { type: function (ui) {
                                           var value = ui.value;
                                           var validationresp = false;
                            var validationmsg = "";
                      
   ====>>>                             // I want to get the value of the column (admin_login_id) and assign it to idvalue variable
   ====>>>                             // Assign a static value for now, until I know how to get the admin_login_id from the grid and assign it

                                               var idvalue = 1;
     
                                          //remote validation
                                          $.ajax({

                                               url: "/logins.cfc?method=validatepwd",
                                               data: { 'password': value, uid: idvalue  },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #1 on: September 24, 2015, 10:54:31 pm »
Every callback has ui.rowData property.

You can get the value from ui.rowData.admin_login_id inside the validation callback.
« Last Edit: September 24, 2015, 11:18:44 pm by paramquery »

gammax500

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #2 on: September 24, 2015, 11:49:11 pm »
There may be an error elsewhere, but I have this code in the callback code.

validations: [

   { type: function (ui) {
                var value = ui.value;
                var idvalue = ui.rowData.admin_login_id;

      alert(value);  -- this is defined and gives the correct value for the selected cell
      alert(idvalue);  -- this is UNdefined
      var validationresp = false;
      var validationmsg = "";

The column model for the ID is.  Do I have that defined correctly?

colModel: [
                { title: "ID", width: 50, dataType: "integer", editable: false , hidden: false , dataIndex: "admin_login_id"  },

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #3 on: September 25, 2015, 10:09:18 am »
Please correct dataIndex to dataIndx in all columns.

There is no 'e' in all *Indx in PQ e.g., rowIndx, rowIndxPage, dataIndx, colIndx

gammax500

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #4 on: September 29, 2015, 12:58:11 am »
When i replace dataIndex with dataIndx, all of the values disappear from my grid.  The grid displays the correct number of records, but the values do not appear.  If I change back to dataIndex, then all the data cells are populated.

My JSON looks like, which corresponds to the order of columns in the colModel:

{"COLUMNS":["ADMIN_LOGIN_ID","FNAME","LNAME","EMAIL","PHONE","PHONE_EXT","PASSWORD","DATE_PASSWORD_CHANGED"
],"DATA":[[474,"Tami","Alleman","[email protected]","541-988-0227","482","David33","May, 08
 2014 20:59:01"],[453,"Patricia","Atkins","[email protected]","541-465-8135","135","Atkinspatricia1"
,"April, 01 2011 00:00:00"],[372,"Barb","Barnard","[email protected]","541-465-8175","175","Realtress421"
,"March, 04 2014 15:51:56"],[386,"David","Baslaw","[email protected]","541-465-8116","116","2014Noah"
,"July, 14 2014 18:02:06"]......

gammax500

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #5 on: September 29, 2015, 02:56:35 am »
I have 2 outstanding issues.   It turns out the real problem with BOTH was the type of JSON format that Coldfusion was returning to the grid. Once I figured that out, I was able to access the other column data with no problem.  That solves this issue.  The other issue had to do with the "red icon" indicator for changed data.  Once this was solved, that one was solved too.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Get value of different cell, while in other selected cell
« Reply #6 on: September 29, 2015, 06:50:21 pm »
That sounds good.