We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Extra row loss after deleteShiftUp() or EntireRow()

function deleteSomething(rowIndex, colIndex) {
var excelObj = $("#Spreadsheet").data("ejSpreadsheet");
var somethingInCellBelow = excelObj.XLEdit.getPropertyValue(rowIndex + 1, colIndex);
excelObj.deleteEntireRow(rowIndex, rowIndex);
excelObj.XLEdit.updateCellValue({ rowIndex: rowIndex, colIndex: 0 }, somethingInCellBelow);
}

We're having issues with both deleting an entire row and deleteShiftUp(), which was:
var startCell= {rowIndex: rowIndex, colIndex: 0}, endCell= {rowIndex: rowIndex, colIndex: 0};
excelObj.deleteShiftUp(startCell, endCell);


For some reason a loss is happening when the functionality occurs:
i.e.
Value 1
Value 2
Value 3
Value 4
Value 5
Value 6
If you were to delete 'Value 3' the proceeding values would shift up but an empty cell is left. See below for example after.. That's why we were just trying to edit after the fact (excelObj.XLEdit.updateCellValue({ rowIndex: rowIndex, colIndex: 0 }, somethingInCellBelow);). 'Value 4' gets "lost".

Value 1
Value 2

Value 5
Value 6

I should also add we'll need a whole range of cells to shift up if not the entire row. Sample data:
Value 1
2



Value 2


1 1
Value 3 1
1 1
1
Value 4
1


1
Value 5
1
1
1
Value 6 1
1 1 1

Desired display after deleting row or shifting cells:


Value 1
2



Value 2


1 1
Value 4
1


1
Value 5
1
1
1
Value 6 1
1 1 1


Thank you for your assistance!

3 Replies

CI Christopher Issac Sunder K Syncfusion Team January 24, 2019 11:46 AM UTC

Hi Jacob, 

Thank you for contacting Syncfusion support. 

We have checked your reported issue by creating the sample based on your provided codes. And we are not able to reproduce it in our end. For your convenience, we have prepared a sample based on your scenario in button click event. Please find the link below. 


Before we proceed further, we would like to know the following details.  

1. Please confirm whether your mentioned variable “somethingInCellBelow” contains value or empty string. 
2. The deleteEntireRow operation deletes the entire row and automatically the bottom cells moved up (Value3 deleted and Value4 moved up) so you don’t need to update the value by using the “updateCellvalue” method. So, please confirm why you have used this method to update the value. 
3. If possible please replicate your issue in the above sample and get back to us. 
4. Please provide your Essential studio product version that you are using. 

Could you please check the above sample and get back to us with the above details based on that we will check and provide you a better solution quickly. 

Thanks, 
Christo  



JK Jacob Knight January 24, 2019 02:52 PM UTC


1. Please confirm whether your mentioned variable “somethingInCellBelow” contains value or empty string.
    A. It contains a value.
 
2. The deleteEntireRow operation deletes the entire row and automatically the bottom cells moved up (Value3 deleted and Value4 moved up) so you don’t need to update the value by using the “updateCellvalue” method. So, please confirm why you have used this method to update the value.
    A. It was an attempt to code around the 2nd value being dropped. Ideally, it wouldn't be necessary.

3. If possible please replicate your issue in the above sample and get back to us.
    Please see provided attachment.

4. Please provide your Essential studio product version that you are using.
    A. Essential Studio Javascript 1

Attachment: RowDeletionBug_8fce218f.zip


SI Silambarasan I Syncfusion Team January 25, 2019 11:44 AM UTC

Hi Jacob, 
 
Thank you for your update. 
 
We have checked your requirement (“To delete the row whether the cell contains the empty value”) with your provided codes in the attachment (RowDeletionBug_8fce218f.zip) and we found that the cause of this is due to performed the delete operation before the save operation get completed since you have used the ‘cellSave’ event - that triggers while saving the edited cell. So, to avoid this issue we suggest you to use the ‘actionComplete’ event instead of ‘cellSave’ event to achieve your requirement as like as in the below modified code example. 
 
[SCRIPT]  
 
$(function () { 
    $("#Spreadsheet").ejSpreadsheet({ 
        sheets: [ 
            { dataSource: defaultData, showHeader: false } 
        ], 
        columnWidth: 90, 
        // cellSave: "delClick" 
        actionComplete: "delClick" 
    }); 
}); 
 
function delClick(args) { 
    var excelObj = $("#Spreadsheet").data("ejSpreadsheet"); 
    if (args.reqType == "edit") { // for cell edit operation 
        if (args.cValue.length === 0 && args.pValue.length > 0) 
        { 
            // condition for current and previous cell value length 
            excelObj.deleteEntireRow(args.rowIndex, args.rowIndex); // to delete the row 
        } 
    } 
} 
 
 
For your convenience, we have modified the sample based on your requirement and the same can be downloaded from the below link. 
 
Sample Link: 
 
Could you please check the above sample & modified code example and get back to us, if you need further assistance on this? 
 
Regards, 
Silambarasan 


Loader.
Live Chat Icon For mobile
Up arrow icon