Author Topic: Mysql's tinyint a ParamQuery's boolean  (Read 2221 times)

ohbayashi

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 41
    • View Profile
Mysql's tinyint a ParamQuery's boolean
« on: March 28, 2017, 11:12:16 am »
MySql
table floor_status
  field visble_flag tinyint  //0:false, 1:true
  ↓
PHP GET
  ↓
ParamQuery...
  grid
    colModel...
      { dataIndx: "visible_flag", dataType: "bool", type: "checkbox" },...
  ↓
| visible | ...
|---|...
| 0 |...          <=   I want to display as 0=true(checked), 1=false(unchecked)
  ↓
PHP POST     <=   false=0 or true=1
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Mysql's tinyint a ParamQuery's boolean
« Reply #1 on: March 28, 2017, 12:30:52 pm »
tinyint (0,1) to boolean(true, false) can be cast in dataModel.getData callback as

data.forEach(function(rd){
  rd.visible_flag = !!rd.visible_flag;
});

ohbayashi

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Mysql's tinyint a ParamQuery's boolean
« Reply #2 on: March 28, 2017, 01:25:28 pm »
Thank you!
I could do it.