Author Topic: How to change the cell data before Validate  (Read 2780 times)

杨万里

  • Newbie
  • *
  • Posts: 25
    • View Profile
How to change the cell data before Validate
« on: May 14, 2018, 10:24:46 am »
How to change the cell data beforeValidate?
 beforeValidate: function( event, ui ) {
      //code   change the cellData before it validate
}

or

Is there  other Events to change then cell's data before validate except beforeValidate?

Thanks.
« Last Edit: May 14, 2018, 10:39:21 am by 杨万里 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to change the cell data before Validate
« Reply #1 on: May 16, 2018, 09:40:49 am »
ui parameter in beforeValidate event is an object contaning source and rowList properties.

Code: [Select]
{
  "source": "edit",
  "checkEditable": false,
  "rowList": [
    {
      "newRow": {
        "ProductName": "paramquery"
      },
      "oldRow": {
        "ProductName": "Tofu"
      },
      "rowData": {
        "ProductID": 14,
        "ProductName": "Tofu",
        "QuantityPerUnit": "40 - 100 g pkgs.",
        "UnitPrice": 23.25,
        "UnitsInStock": 35,
        "UnitsOnOrder": 0,
        "ReorderLevel": 0,
        "Discontinued": false,
        "pq_cellselect": {
          "ProductName": true
        }
      },
      "rowIndx": 69,
      "type": "update"
    }
  ]
}

Depends on what you want to do with it. It's manipulation is done the way you normally modify plain objects and arrays.

Typical example:

Code: [Select]
if( ui.source == 'edit' ){
  ui.rowList.forEach( function ( obj ){
     obj.newRow.ProductName = "Hello world";
  })
}

杨万里

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: How to change the cell data before Validate
« Reply #2 on: May 17, 2018, 10:28:46 am »
 :) :) :) :) :)
It is work!
you gave me great help.
I really thank you very much!