Author Topic: Dynamically change the dataType of the column after adding new column???  (Read 2124 times)

conx

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
I added a new column which is on string by default, so I need to change one of the columns to date format and other to the integer format from the front-end view, is there any functions on toolbar which can be used to dynamically change the data type of the column after its been created????

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Please use getColumn method to get column and change its properties.

https://paramquery.com/pro/api#method-getColumn

Code: [Select]
listener: function () {
   this.getColumn({dataIndx: dataIndx of field}).dataType = "integer";
}

conx

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
i got it, this code can be done from backend but in spreadsheet/worksheet how can i select the column and have options to change the datatypes?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
The above method is for changing dataType from toolbar and selected column's dataIndx or colIndx can be obtained from Selection().address() method.

https://paramquery.com/pro/api#method-Range

https://paramquery.com/pro/api#method-Selection

Alternatively it can also be done from context menu ( easier way ).

Code: [Select]
action: function (evt, ui) {        
ui.column.dataType = "integer";
}
« Last Edit: May 11, 2020, 03:55:23 pm by paramvir »