Ranjith V
Ranjith V

Reputation: 298

Jqgrid edit event for displaying server side validation result

I'm using inline edit and delete functionality. I'm not using any editGridRow or delGridRow methods explicitly. I need to validate the data on the server side and display the results. In case of deleting, I have many events under delOptions property like afterSubmit, afterComplete. But for editing, I don't know the event that I should use to get the validation result from server and display it to user. Suggestions ?

//My action colmodel

colEditModel = {
            name: "actions",
            width: 90,
            formatter: "actions",
            sortable: false,
            search: false,
            formatoptions: {
                keys: true,
                editOptions: {},
                addOptions: {},
                delOptions: {
                    onclickSubmit: function (options) {
                        options.delData = {//Some data};
                        options.url = "Allocation/EditAllocation";
                    },
                }
            }
        };

// Grid

$("#jqGrid").jqGrid({
            url: "Allocation/GetAllocations",
            mtype: "GET",
            datatype: "json",
            colModel: col_model,
            colNames: col_names,
            postData: { selectedDate: dateValue, filterCriteria: criteria },
            editurl: "Allocation/EditAllocation",
            serializeRowData: function (postdata) {
                var requestData = { // some data};
                return requestData;
            },
            loadonce: true,
            viewrecords: false,
            height: 330,
            width: null,
            shrinkToFit: false,
            autoheight: true,
            pager: "#jqGridPager",
            scroll: false,
            rownumbers: false,
            treeGrid: false,
            gridview: true,

        });

Upvotes: 0

Views: 207

Answers (1)

Oleg
Oleg

Reputation: 221997

The exact implementation depand on the version of jqGrid which you use and from the fork of jqGrid which you use. If you use an old version of jqGrid then you can specify onError callback inside of formatoptions of formatter: "actions" to process errors of inline editing and to use delOptions.errorTextFormat (the errorTextFormat callback, which you have to define inside of the delOptions property of formatoptions).

It's important to understand, that server side validation is the same as any other the error reporting from the server. The server should return the error description as HTML fragments. The response have to use any error HTML status code (the value >=400).

Upvotes: 1

Related Questions