How to disable delete for certain rows please

Posted by: szilbermints on 12 February 2019, 11:03 am EST

    • Post Options:
    • Link

    Posted 12 February 2019, 11:03 am EST

    Hi,

    I want to make some rows non editable and non deletable.

    The following forks fine to disable editing for some rows but still allows to delete:

    		  fpSpread1.Sheets(0).Rows(jj).Locked = True
                        fpSpread1.Sheets(0).Rows(jj).CanFocus = False
    

    Can you please specify if it can be done in server side code and how?

    Thank You

  • Posted 12 February 2019, 6:54 pm EST

    Hello,

    Please have a look at client side script code that shows how to disable the delete button for specific rows:-

    
    <script>
        window.onload = function () {
          $$.j("#FpSpread1").on("ActiveCellChanged", function (e) {
            var event = e.originalEvent;
            var selectedRow = event.Row;
            //alert("Selected row " + selectedRow);
    
            disableButton(!isAllowDelete(selectedRow));
          });
        }
    
        var deleteButton = null;
        function disableButton(disabled) {
          if (deleteButton == null) {
            var imgs = $$.j("#FpSpread1 div.commandBar img");
            for (var i = 0; i < imgs.length; i++) {
              var $img = $$.j(imgs.get(i));
              if ($img.attr("onclick").indexOf(".Delete()") != -1) {
                // Disable delete button
                deleteButton = $img;
                break;
              }
            }
          }
    
          if (deleteButton != null)
            deleteButton.attr("src", disabled ? deleteButton.attr("disabledimg") : deleteButton.attr("enabledimg"));
        }
    
        function isAllowDelete(row) {
          /// <summary>Indicate whether a row is fine to delete</summary>
    
          return row != 1;
        }
      </script>
    
    

    Please have a look at attached sample as well for the same. Hope it helps.

    Thanks,

    Reeva

    WebApplication1.zip

  • Posted 13 February 2019, 1:32 am EST

    Thank You

    Any way to use property or something to do it with Server side code ?

    s

  • Posted 13 February 2019, 6:03 pm EST

    Hello,

    Unfortunately, there isn’t any direct server side property to achieve the same.

    We regret the inconvenience.

    Thanks,

    Reeva

Need extra support?

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

Learn More

Forum Channels