myliang / x-spreadsheet

The project has been migrated to @wolf-table/table https://github.com/wolf-table/table
https://myliang.github.io/x-spreadsheet
MIT License
14.2k stars 1.71k forks source link

How can I add data validaton to cells From JS #351

Open helmidhaoui opened 4 years ago

helmidhaoui commented 4 years ago

How can I add a data validation to a specifique cell from JS.

gxxgo commented 3 years ago
xs.datas[0].addValidation('cell', 'A1:A2', {
          type: 'list',
          required: false,
          value: 'a,b,c',
          operator: 'be'
        })

Method: addValidation(mode, ref, validator)

@param mode //'cell'

@param ref //string like:'A1:A2'

@param validator //object

{
  type:'list',// date|number|list|phone|email
  required:false, //false or true
  value:'a,b,c', // separated with ','
  operator:'be'//operator: be(between)|nbe|eq(equal)|neq|lt(less than)|lte|gt(greater than)|gte
}
Nihal-Chandwani commented 2 weeks ago

did this work for your guys?