Disable editing for certain rows

Posted by: johngiblin on 2 April 2020, 3:23 pm EST

    • Post Options:
    • Link

    Posted 2 April 2020, 3:23 pm EST

    I wanted to be able to disable certain rows from being able to be editable.

    I tried the following, where I have a field called isDetail and I use the stopEditing when the status is beforeStartEditing. That doesnt seem to work

    private editingDataView(sender: any, args: any): void {

    if (args.oldItem.isDetail === false) {
      if (args.status === 'beforeStartEditing') {
          this.dataView.stopEditing();
      }
      return;
    }
    
  • Posted 2 April 2020, 3:24 pm EST

    [author]johngiblin[/author]I wanted to be able to disable certain rows from being able to be editable.

    I tried the following, where I have a field called isDetail and I use the stopEditing when the status is beforeStartEditing. That doesnt seem to work

    private editingDataView(sender: any, args: any): void {

        if (args.oldItem.isDetail === false) {
          if (args.status === 'beforeStartEditing') {
              this.dataView.stopEditing();
          }
          return;
        }
    
  • Posted 3 April 2020, 2:49 am EST

    Hi John,

    You need to set the cancel property to true for beforeStartEditing edit event.Please refer to the following code snippet and the sample demonstrating the same:

    dataView.editing.addHandler(function(e) {
      if (e.status === 'beforeStartEditing' && !e.oldItem.isDetail) {
        e.cancel = true;
      }
    });
    

    https://www.grapecity.com/dataviewsjs/demos/Features/Editing/LockRow/purejs

    Regards

    Sharad

  • Posted 6 April 2020, 9:18 am EST

    Thanks Sharad. that worked!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels