Is there any way that I can exclude specific columns from posting to the controller after "saveChanges" event called in the igGrid?

Example:

    $("#{{gridName}}").igGrid({
        autoGenerateColumns: false,
        primaryKey: "id",
        columns: JSON.parse('{{igniteTableColumns|raw}}'),
        updateUrl: "/path-to-controller-action",
        features: [               
            {
                name : 'Updating',
                enableAddRow: false,
                enableDeleteRow: false,
                saveChangesSuccessHandler : function (data) {
                    $("#message").text("Changes were saved successfully").fadeIn(3000).fadeOut(5000);                        
                },
                columnSettings: [ 
                    {
                        columnKey: "id",
                        editorOptions: {
                            readOnly: true
                        }
                    }, 
                    {
                        columnKey: "event_date",
                        editorType: 'datepicker',
                        validation: true,
                        editorOptions: {
                            dateFormat: 'MM-dd-yy',
                            required: true,
                            dropDownTriggers: 'focus'
                        }
                    },
                    {
                        columnKey: "event",
                        editorType: 'text',
                        validation: true,
                        editorOptions: {
                            required: true
                        }
                    },                        
                    {
                        columnKey: "history",
                        editorOptions: {
                            readOnly: true
                        }
                    },
                    {
                        columnKey: "delete",
                        editorOptions: {
                            readOnly: true
                        }
                    }
                ]
            }
        ],
        width: "100%",            
        autoCommit: true,
        dataSource: JSON.parse('{{igniteTableData|raw}}'),
        dataSourceType: "json",
        responseDataKey: "igniteTableData"
    });

    $("#saveChanges").click(function () {    
        $("#{{gridName}}").igGrid("saveChanges");    
    });

In the above example, all the specified columns are posting to the controller. But I want to exclude the "history" and "delete" columns from the post data.

Because I don't want to go through each array and manually remove these columns from the post data before pushing the data to the data base to save.

1

There are 1 best solutions below

0
On

In general, the control assumes that you want to be posting the whole entity it has been bound to back to your service. If you want, you can modify the pending transactions object before calling saveChanges.

var trasnactions = $("#{{gridName}}").igGrid("option", "dataSource").pendingTransactions();  

https://www.igniteui.com/help/api/2018.2/ig.datasource#methods:pendingTransactions