Author Topic: Check for null cell change in batch editing  (Read 1773 times)

luckduck

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 46
    • View Profile
Check for null cell change in batch editing
« on: November 17, 2020, 01:12:21 pm »
If you double-click an empty cell without a value (editing begin) and then enter or move to another cell (editing end), it is recognized as changed even though there is no changed value.

https://paramquery.com/pro/demos/editing_batch


1. Add one blank cell in the batch editing demo above
Code: [Select]
                {
                    title: "Unit Price", width: 100, dataType: "float", dataIndx: "UnitPrice",
                    validations: [{ type: 'gt', value: 0.5, msg: "should be > 0.5" }],
                    render: function (ui) {
                        var cellData = ui.cellData;
                        if (cellData != null) {
                            return "$" + parseFloat(ui.cellData).toFixed(2);
                        }
                        else {
                            return "";
                        }
                    }
                },
                {
                    title: "TEST", width: 100
                },

2. Test cell double click

3. Click Enter or Tap or click elsewhere

4. There is no change in the value of the test cell, but it is displayed as changed.

How do I mark it as unchanged?

Thank you.



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Check for null cell change in batch editing
« Reply #1 on: November 17, 2020, 01:36:28 pm »
When nothing is entered in the editor, editor value is returned as "" which doesn't match with previous null or undefined value and the cell is marked as dirty.

To prevent it, column.editor.getData callback can be used.

Code: [Select]
editor:{
getData: function(ui){
var val = ui.$cell.find(".pq-cell-editor").val();
return val===""? null: val;
}
}
« Last Edit: November 17, 2020, 01:42:53 pm by paramvir »

luckduck

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Check for null cell change in batch editing
« Reply #2 on: November 18, 2020, 07:03:30 am »
Thank you.

I applied the source but it is the same as before.


https://jsfiddle.net/kgfp5vs4/

Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Check for null cell change in batch editing
« Reply #3 on: November 18, 2020, 10:25:58 am »
Please change from null to undefined.

Code: [Select]
editor:{
getData: function(ui){
var val = ui.$cell.find(".pq-cell-editor").val();
return val===""? undefined: val;
}
}

https://jsfiddle.net/6avcn42k/