单击外部按钮时验证Syncfusion JavaScript电子表格

a14dhokn  于 2023-02-07  发布在  Java
关注(0)|答案(1)|浏览(112)

我有下面的Syncfusion JavaScript电子表格.
我在页面上有外部按钮,我想验证并突出显示按钮点击时无效的行。我该怎么做?

var sheet = [

  {
    ranges: [{
      dataSource: tradeData
    }],
    fieldAsColumnHeader: true,
    columns: [{
        width: 70
      }, {
        width: 80
      }, {
        width: 100
      }, {
        width: 100
      },
      {
        width: 70
      }, {
        width: 120
      }, {
        width: 80
      }, {
        width: 120
      },
      {
        width: 140
      }, {
        width: 80
      }, {
        width: 120
      }, {
        width: 120
      }
    ],
    rows: [{
      index: 1,
      cells: [{
          index: 3,
          value: '',
          validation: {
            type: 'List',
            value1: trade_types.toString()
          }
        },
        {
          index: 8,
          value: '',
          validation: {
            type: 'List',
            value1: counter_parties.toString()
          }
        },
        {
          index: 10,
          value: '',
          validation: {
            type: 'List',
            value1: settlement_methods.toString()
          }
        }
      ]
    }]
  }
];

var spreadsheet = new ej.spreadsheet.Spreadsheet({
  showRibbon: false,
  showFormulaBar: false,
  showSheetTabs: false,
  sheets: sheet,
  created: () => {
    //Add Data validation to range.
  }

});

spreadsheet.appendTo('#spreadsheet');
document.getElementById("btn").onclick = () => {
    // Get the data of the spreadsheet.
    //Validate data like if the cell value is null or empty, if the value is Invalid, 
    //the highlight the cell with Yellow color(Default is yellow color)
  };
inn6fuwd

inn6fuwd1#

通过addDataValidation方法为单元格区域添加数据验证即可满足您的要求,并通过addInvalidHighlight方法突出显示验证应用区域的无效数据,为方便您使用,我们根据您的要求准备了示例,您可以在下面的链接中找到它。
示例链接:https://stackblitz.com/edit/c18zk5?file=index.js,index.html
文档链接:www.example.comhttps://ej2.syncfusion.com/documentation/spreadsheet/cell-range/#data-validation
API链接:www.example.comhttps://ej2.syncfusion.com/documentation/api/spreadsheet/#addinvalidhighlight
https://ej2.syncfusion.com/documentation/api/spreadsheet/#adddatavalidation

相关问题