ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: luckduck on November 17, 2020, 01:12:21 pm

Title: Check for null cell change in batch editing
Post by: luckduck 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.


Title: Re: Check for null cell change in batch editing
Post by: paramvir 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;
}
}
Title: Re: Check for null cell change in batch editing
Post by: luckduck 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.
Title: Re: Check for null cell change in batch editing
Post by: paramvir 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/